mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
cd9036adaf
@ -16,13 +16,7 @@ export async function deleteUser(userId) {
|
|||||||
|
|
||||||
return client
|
return client
|
||||||
.$transaction([
|
.$transaction([
|
||||||
client.pageview.deleteMany({
|
client.websiteEvent.deleteMany({
|
||||||
where: { websiteId: { in: websiteIds } },
|
|
||||||
}),
|
|
||||||
client.eventData.deleteMany({
|
|
||||||
where: { event: { websiteId: { in: websiteIds } } },
|
|
||||||
}),
|
|
||||||
client.event.deleteMany({
|
|
||||||
where: { websiteId: { in: websiteIds } },
|
where: { websiteId: { in: websiteIds } },
|
||||||
}),
|
}),
|
||||||
client.session.deleteMany({
|
client.session.deleteMany({
|
||||||
|
@ -5,13 +5,7 @@ export async function deleteWebsite(id) {
|
|||||||
const { client, transaction } = prisma;
|
const { client, transaction } = prisma;
|
||||||
|
|
||||||
return transaction([
|
return transaction([
|
||||||
client.pageview.deleteMany({
|
client.websiteEvent.deleteMany({
|
||||||
where: { websiteId: id },
|
|
||||||
}),
|
|
||||||
client.eventData.deleteMany({
|
|
||||||
where: { event: { websiteId: id } },
|
|
||||||
}),
|
|
||||||
client.event.deleteMany({
|
|
||||||
where: { websiteId: id },
|
where: { websiteId: id },
|
||||||
}),
|
}),
|
||||||
client.session.deleteMany({
|
client.session.deleteMany({
|
||||||
|
@ -1,20 +1,25 @@
|
|||||||
import prisma from 'lib/prisma';
|
import prisma from 'lib/prisma';
|
||||||
|
import { getWebsite } from 'queries';
|
||||||
|
import cache from 'lib/cache';
|
||||||
|
|
||||||
export async function resetWebsite(id) {
|
export async function resetWebsite(id) {
|
||||||
const { client, transaction } = prisma;
|
const { client, transaction } = prisma;
|
||||||
|
|
||||||
|
const { revId } = await getWebsite({ id });
|
||||||
|
|
||||||
return transaction([
|
return transaction([
|
||||||
client.pageview.deleteMany({
|
client.websiteEvent.deleteMany({
|
||||||
where: { websiteId: id },
|
|
||||||
}),
|
|
||||||
client.eventData.deleteMany({
|
|
||||||
where: { event: { websiteId: id } },
|
|
||||||
}),
|
|
||||||
client.event.deleteMany({
|
|
||||||
where: { websiteId: id },
|
where: { websiteId: id },
|
||||||
}),
|
}),
|
||||||
client.session.deleteMany({
|
client.session.deleteMany({
|
||||||
where: { websiteId: id },
|
where: { websiteId: id },
|
||||||
}),
|
}),
|
||||||
]);
|
client.website.update({ where: { id }, data: { revId: revId + 1 } }),
|
||||||
|
]).then(async data => {
|
||||||
|
if (cache.enabled) {
|
||||||
|
await cache.storeWebsite(data[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@ async function clickhouseQuery(
|
|||||||
from event
|
from event
|
||||||
where event_name = ''
|
where event_name = ''
|
||||||
and website_id = $1
|
and website_id = $1
|
||||||
|
and rev_id = $2
|
||||||
and ${getBetweenDates('created_at', start_at, end_at)}
|
and ${getBetweenDates('created_at', start_at, end_at)}
|
||||||
${pageviewQuery}
|
${pageviewQuery}
|
||||||
${sessionQuery}
|
${sessionQuery}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import prisma from 'lib/prisma';
|
import prisma from 'lib/prisma';
|
||||||
import clickhouse from 'lib/clickhouse';
|
import clickhouse from 'lib/clickhouse';
|
||||||
import { runQuery, CLICKHOUSE, PRISMA } from 'lib/db';
|
import { runQuery, CLICKHOUSE, PRISMA } from 'lib/db';
|
||||||
|
import cache from 'lib/cache';
|
||||||
|
|
||||||
export async function getWebsiteStats(...args) {
|
export async function getWebsiteStats(...args) {
|
||||||
return runQuery({
|
return runQuery({
|
||||||
@ -45,7 +46,8 @@ async function relationalQuery(websiteId, { start_at, end_at, filters = {} }) {
|
|||||||
|
|
||||||
async function clickhouseQuery(websiteId, { start_at, end_at, filters = {} }) {
|
async function clickhouseQuery(websiteId, { start_at, end_at, filters = {} }) {
|
||||||
const { rawQuery, getDateQuery, getBetweenDates, parseFilters } = clickhouse;
|
const { rawQuery, getDateQuery, getBetweenDates, parseFilters } = clickhouse;
|
||||||
const params = [websiteId];
|
const website = await cache.fetchWebsite(websiteId);
|
||||||
|
const params = [websiteId, website?.revId || 0];
|
||||||
const { pageviewQuery, sessionQuery } = parseFilters(null, filters, params);
|
const { pageviewQuery, sessionQuery } = parseFilters(null, filters, params);
|
||||||
|
|
||||||
return rawQuery(
|
return rawQuery(
|
||||||
@ -63,6 +65,7 @@ async function clickhouseQuery(websiteId, { start_at, end_at, filters = {} }) {
|
|||||||
from event
|
from event
|
||||||
where event_name = ''
|
where event_name = ''
|
||||||
and website_id = $1
|
and website_id = $1
|
||||||
|
and rev_id = $2
|
||||||
and ${getBetweenDates('created_at', start_at, end_at)}
|
and ${getBetweenDates('created_at', start_at, end_at)}
|
||||||
${pageviewQuery}
|
${pageviewQuery}
|
||||||
${sessionQuery}
|
${sessionQuery}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user