mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Merge branch 'dev' into feat/um-66-update-clickhouse-schema-uuid
This commit is contained in:
commit
ec6454aead
65 changed files with 436 additions and 441 deletions
|
|
@ -1,40 +1,40 @@
|
|||
import prisma from 'lib/prisma';
|
||||
import redis, { DELETED } from 'lib/redis';
|
||||
|
||||
export async function deleteAccount(user_id) {
|
||||
export async function deleteAccount(userId) {
|
||||
const { client } = prisma;
|
||||
|
||||
const websites = await client.website.findMany({
|
||||
where: { user_id },
|
||||
select: { website_uuid: true },
|
||||
where: { userId },
|
||||
select: { websiteUuid: true },
|
||||
});
|
||||
|
||||
let websiteUuids = [];
|
||||
|
||||
if (websites.length > 0) {
|
||||
websiteUuids = websites.map(a => a.website_uuid);
|
||||
websiteUuids = websites.map(a => a.websiteUuid);
|
||||
}
|
||||
|
||||
return client
|
||||
.$transaction([
|
||||
client.pageview.deleteMany({
|
||||
where: { session: { website: { user_id } } },
|
||||
where: { session: { website: { userId } } },
|
||||
}),
|
||||
client.event_data.deleteMany({
|
||||
where: { event: { session: { website: { user_id } } } },
|
||||
client.eventData.deleteMany({
|
||||
where: { event: { session: { website: { userId } } } },
|
||||
}),
|
||||
client.event.deleteMany({
|
||||
where: { session: { website: { user_id } } },
|
||||
where: { session: { website: { userId } } },
|
||||
}),
|
||||
client.session.deleteMany({
|
||||
where: { website: { user_id } },
|
||||
where: { website: { userId } },
|
||||
}),
|
||||
client.website.deleteMany({
|
||||
where: { user_id },
|
||||
where: { userId },
|
||||
}),
|
||||
client.account.delete({
|
||||
where: {
|
||||
user_id,
|
||||
id: userId,
|
||||
},
|
||||
}),
|
||||
])
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import prisma from 'lib/prisma';
|
||||
|
||||
export async function getAccountById(user_id) {
|
||||
export async function getAccountById(userId) {
|
||||
return prisma.client.account.findUnique({
|
||||
where: {
|
||||
user_id,
|
||||
id: userId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,17 +3,17 @@ import prisma from 'lib/prisma';
|
|||
export async function getAccounts() {
|
||||
return prisma.client.account.findMany({
|
||||
orderBy: [
|
||||
{ is_admin: 'desc' },
|
||||
{ isAdmin: 'desc' },
|
||||
{
|
||||
username: 'asc',
|
||||
},
|
||||
],
|
||||
select: {
|
||||
user_id: true,
|
||||
id: true,
|
||||
username: true,
|
||||
is_admin: true,
|
||||
created_at: true,
|
||||
updated_at: true,
|
||||
isAdmin: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import prisma from 'lib/prisma';
|
||||
|
||||
export async function updateAccount(user_id, data) {
|
||||
export async function updateAccount(userId, data) {
|
||||
return prisma.client.account.update({
|
||||
where: {
|
||||
user_id,
|
||||
id: userId,
|
||||
},
|
||||
data,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
import prisma from 'lib/prisma';
|
||||
import redis from 'lib/redis';
|
||||
|
||||
export async function createWebsite(user_id, data) {
|
||||
export async function createWebsite(userId, data) {
|
||||
return prisma.client.website
|
||||
.create({
|
||||
data: {
|
||||
account: {
|
||||
connect: {
|
||||
user_id,
|
||||
id: userId,
|
||||
},
|
||||
},
|
||||
...data,
|
||||
|
|
@ -15,7 +15,7 @@ export async function createWebsite(user_id, data) {
|
|||
})
|
||||
.then(async res => {
|
||||
if (redis.client && res) {
|
||||
await redis.client.set(`website:${res.website_uuid}`, res.website_id);
|
||||
await redis.client.set(`website:${res.websiteUuid}`, res.id);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -2,30 +2,30 @@ import prisma from 'lib/prisma';
|
|||
import redis, { DELETED } from 'lib/redis';
|
||||
import { getWebsiteById } from 'queries';
|
||||
|
||||
export async function deleteWebsite(website_id) {
|
||||
export async function deleteWebsite(websiteId) {
|
||||
const { client, transaction } = prisma;
|
||||
|
||||
const { website_uuid } = await getWebsiteById(website_id);
|
||||
const { websiteUuid } = await getWebsiteById(websiteId);
|
||||
|
||||
return transaction([
|
||||
client.pageview.deleteMany({
|
||||
where: { session: { website: { website_id } } },
|
||||
where: { session: { website: { id: websiteId } } },
|
||||
}),
|
||||
client.event_data.deleteMany({
|
||||
where: { event: { session: { website: { website_id } } } },
|
||||
client.eventData.deleteMany({
|
||||
where: { event: { session: { website: { id: websiteId } } } },
|
||||
}),
|
||||
client.event.deleteMany({
|
||||
where: { session: { website: { website_id } } },
|
||||
where: { session: { website: { id: websiteId } } },
|
||||
}),
|
||||
client.session.deleteMany({
|
||||
where: { website: { website_id } },
|
||||
where: { website: { id: websiteId } },
|
||||
}),
|
||||
client.website.delete({
|
||||
where: { website_id },
|
||||
where: { id: websiteId },
|
||||
}),
|
||||
]).then(async res => {
|
||||
if (redis.client) {
|
||||
await redis.client.set(`website:${website_uuid}`, DELETED);
|
||||
await redis.client.set(`website:${websiteUuid}`, DELETED);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ export async function getAllWebsites() {
|
|||
let data = await prisma.client.website.findMany({
|
||||
orderBy: [
|
||||
{
|
||||
user_id: 'asc',
|
||||
userId: 'asc',
|
||||
},
|
||||
{
|
||||
name: 'asc',
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import prisma from 'lib/prisma';
|
||||
|
||||
export async function getUserWebsites(user_id) {
|
||||
export async function getUserWebsites(userId) {
|
||||
return prisma.client.website.findMany({
|
||||
where: {
|
||||
user_id,
|
||||
userId,
|
||||
},
|
||||
orderBy: {
|
||||
name: 'asc',
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import prisma from 'lib/prisma';
|
||||
|
||||
export async function getWebsiteById(website_id) {
|
||||
export async function getWebsiteById(websiteId) {
|
||||
return prisma.client.website.findUnique({
|
||||
where: {
|
||||
website_id,
|
||||
id: websiteId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import prisma from 'lib/prisma';
|
||||
|
||||
export async function getWebsiteByShareId(share_id) {
|
||||
export async function getWebsiteByShareId(shareId) {
|
||||
return prisma.client.website.findUnique({
|
||||
where: {
|
||||
share_id,
|
||||
shareId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
import prisma from 'lib/prisma';
|
||||
import redis from 'lib/redis';
|
||||
|
||||
export async function getWebsiteByUuid(website_uuid) {
|
||||
export async function getWebsiteByUuid(websiteUuid) {
|
||||
return prisma.client.website
|
||||
.findUnique({
|
||||
where: {
|
||||
website_uuid,
|
||||
websiteUuid,
|
||||
},
|
||||
})
|
||||
.then(async res => {
|
||||
if (redis.client && res) {
|
||||
await redis.client.set(`website:${res.website_uuid}`, res.website_id);
|
||||
await redis.client.set(`website:${res.websiteUuid}`, res.id);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
import prisma from 'lib/prisma';
|
||||
|
||||
export async function resetWebsite(website_id) {
|
||||
export async function resetWebsite(websiteId) {
|
||||
const { client, transaction } = prisma;
|
||||
|
||||
return transaction([
|
||||
client.pageview.deleteMany({
|
||||
where: { session: { website: { website_id } } },
|
||||
where: { session: { website: { id: websiteId } } },
|
||||
}),
|
||||
client.event_data.deleteMany({
|
||||
where: { event: { session: { website: { website_id } } } },
|
||||
client.eventData.deleteMany({
|
||||
where: { event: { session: { website: { id: websiteId } } } },
|
||||
}),
|
||||
client.event.deleteMany({
|
||||
where: { session: { website: { website_id } } },
|
||||
where: { session: { website: { id: websiteId } } },
|
||||
}),
|
||||
client.session.deleteMany({
|
||||
where: { website: { website_id } },
|
||||
where: { website: { id: websiteId } },
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export async function getEventMetrics(...args) {
|
|||
}
|
||||
|
||||
async function relationalQuery(
|
||||
website_id,
|
||||
websiteId,
|
||||
start_at,
|
||||
end_at,
|
||||
timezone = 'utc',
|
||||
|
|
@ -18,7 +18,7 @@ async function relationalQuery(
|
|||
filters = {},
|
||||
) {
|
||||
const { rawQuery, getDateQuery, getFilterQuery } = prisma;
|
||||
const params = [website_id, start_at, end_at];
|
||||
const params = [websiteId, start_at, end_at];
|
||||
|
||||
return rawQuery(
|
||||
`select
|
||||
|
|
@ -36,6 +36,7 @@ async function relationalQuery(
|
|||
}
|
||||
|
||||
async function clickhouseQuery(
|
||||
websiteId,
|
||||
website_uuid,
|
||||
start_at,
|
||||
end_at,
|
||||
|
|
@ -44,7 +45,7 @@ async function clickhouseQuery(
|
|||
filters = {},
|
||||
) {
|
||||
const { rawQuery, getDateQuery, getBetweenDates, getFilterQuery } = clickhouse;
|
||||
const params = [website_uuid];
|
||||
const params = [websiteId];
|
||||
|
||||
return rawQuery(
|
||||
`select
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ function relationalQuery(websites, start_at) {
|
|||
return prisma.client.event.findMany({
|
||||
where: {
|
||||
website: {
|
||||
website_id: {
|
||||
id: {
|
||||
in: websites,
|
||||
},
|
||||
},
|
||||
created_at: {
|
||||
createdAt: {
|
||||
gte: start_at,
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -10,18 +10,18 @@ export async function saveEvent(...args) {
|
|||
});
|
||||
}
|
||||
|
||||
async function relationalQuery(website_id, { session_id, url, event_name, event_data }) {
|
||||
async function relationalQuery(websiteId, { sessionId, url, eventName, eventData }) {
|
||||
const data = {
|
||||
website_id,
|
||||
session_id,
|
||||
websiteId,
|
||||
sessionId,
|
||||
url: url?.substring(0, URL_LENGTH),
|
||||
event_name: event_name?.substring(0, EVENT_NAME_LENGTH),
|
||||
eventName: eventName?.substring(0, EVENT_NAME_LENGTH),
|
||||
};
|
||||
|
||||
if (event_data) {
|
||||
data.event_data = {
|
||||
if (eventData) {
|
||||
data.eventData = {
|
||||
create: {
|
||||
event_data: event_data,
|
||||
eventData: eventData,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
@ -32,18 +32,21 @@ async function relationalQuery(website_id, { session_id, url, event_name, event_
|
|||
}
|
||||
|
||||
async function clickhouseQuery(
|
||||
websiteId,
|
||||
{ session: { country, sessionUuid, ...sessionArgs }, eventUuid, url, eventName, eventData },
|
||||
website_uuid,
|
||||
{ session: { country, ...sessionArgs }, event_uuid, url, event_name, event_data },
|
||||
) {
|
||||
const { getDateFormat, sendMessage } = kafka;
|
||||
|
||||
const params = {
|
||||
event_uuid,
|
||||
session_uuid: sessionUuid,
|
||||
event_uuid: eventUuid,
|
||||
website_id: websiteId,
|
||||
website_uuid,
|
||||
created_at: getDateFormat(new Date()),
|
||||
url: url?.substring(0, URL_LENGTH),
|
||||
event_name: event_name?.substring(0, EVENT_NAME_LENGTH),
|
||||
event_data: JSON.stringify(event_data),
|
||||
event_name: eventName?.substring(0, EVENT_NAME_LENGTH),
|
||||
event_data: JSON.stringify(eventData),
|
||||
...sessionArgs,
|
||||
country: country ? country : null,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ export async function getPageviewMetrics(...args) {
|
|||
});
|
||||
}
|
||||
|
||||
async function relationalQuery(website_id, { startDate, endDate, column, table, filters = {} }) {
|
||||
async function relationalQuery(websiteId, { startDate, endDate, column, table, filters = {} }) {
|
||||
const { rawQuery, parseFilters } = prisma;
|
||||
const params = [website_id, startDate, endDate];
|
||||
const params = [websiteId, startDate, endDate];
|
||||
const { pageviewQuery, sessionQuery, eventQuery, joinSession } = parseFilters(
|
||||
table,
|
||||
column,
|
||||
|
|
@ -34,9 +34,9 @@ async function relationalQuery(website_id, { startDate, endDate, column, table,
|
|||
);
|
||||
}
|
||||
|
||||
async function clickhouseQuery(website_uuid, { startDate, endDate, column, filters = {} }) {
|
||||
async function clickhouseQuery(websiteId, { startDate, endDate, column, filters = {} }) {
|
||||
const { rawQuery, parseFilters, getBetweenDates } = clickhouse;
|
||||
const params = [website_uuid];
|
||||
const params = [websiteId];
|
||||
const { pageviewQuery, sessionQuery, eventQuery } = parseFilters(column, filters, params);
|
||||
|
||||
return rawQuery(
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ export async function getPageviewParams(...args) {
|
|||
});
|
||||
}
|
||||
|
||||
async function relationalQuery(website_id, start_at, end_at, column, table, filters = {}) {
|
||||
async function relationalQuery(websiteId, start_at, end_at, column, table, filters = {}) {
|
||||
const { parseFilters, rawQuery } = prisma;
|
||||
const params = [website_id, start_at, end_at];
|
||||
const params = [websiteId, start_at, end_at];
|
||||
const { pageviewQuery, sessionQuery, eventQuery, joinSession } = parseFilters(
|
||||
table,
|
||||
column,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export async function getPageviewStats(...args) {
|
|||
}
|
||||
|
||||
async function relationalQuery(
|
||||
website_id,
|
||||
websiteId,
|
||||
{
|
||||
start_at,
|
||||
end_at,
|
||||
|
|
@ -22,7 +22,7 @@ async function relationalQuery(
|
|||
},
|
||||
) {
|
||||
const { getDateQuery, parseFilters, rawQuery } = prisma;
|
||||
const params = [website_id, start_at, end_at];
|
||||
const params = [websiteId, start_at, end_at];
|
||||
const { pageviewQuery, sessionQuery, joinSession } = parseFilters(
|
||||
'pageview',
|
||||
null,
|
||||
|
|
@ -45,11 +45,11 @@ async function relationalQuery(
|
|||
}
|
||||
|
||||
async function clickhouseQuery(
|
||||
website_uuid,
|
||||
websiteId,
|
||||
{ start_at, end_at, timezone = 'UTC', unit = 'day', count = '*', filters = {} },
|
||||
) {
|
||||
const { parseFilters, rawQuery, getDateStringQuery, getDateQuery, getBetweenDates } = clickhouse;
|
||||
const params = [website_uuid];
|
||||
const params = [websiteId];
|
||||
const { pageviewQuery, sessionQuery } = parseFilters(null, filters, params);
|
||||
|
||||
return rawQuery(
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ async function relationalQuery(websites, start_at) {
|
|||
return prisma.client.pageview.findMany({
|
||||
where: {
|
||||
website: {
|
||||
website_id: {
|
||||
id: {
|
||||
in: websites,
|
||||
},
|
||||
},
|
||||
created_at: {
|
||||
createdAt: {
|
||||
gte: start_at,
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ export async function savePageView(...args) {
|
|||
});
|
||||
}
|
||||
|
||||
async function relationalQuery(website_id, { session: { session_id }, url, referrer }) {
|
||||
async function relationalQuery(websiteId, { session: { sessionId }, url, referrer }) {
|
||||
return prisma.client.pageview.create({
|
||||
data: {
|
||||
website_id,
|
||||
session_id,
|
||||
websiteId,
|
||||
sessionId,
|
||||
url: url?.substring(0, URL_LENGTH),
|
||||
referrer: referrer?.substring(0, URL_LENGTH),
|
||||
},
|
||||
|
|
@ -22,12 +22,13 @@ async function relationalQuery(website_id, { session: { session_id }, url, refer
|
|||
}
|
||||
|
||||
async function clickhouseQuery(
|
||||
website_uuid,
|
||||
{ session: { country, ...sessionArgs }, url, referrer },
|
||||
websiteId,
|
||||
{ session: { country, sessionUuid, ...sessionArgs }, url, referrer },
|
||||
) {
|
||||
const { getDateFormat, sendMessage } = kafka;
|
||||
const params = {
|
||||
website_id: website_uuid,
|
||||
session_uuid: sessionUuid,
|
||||
website_id: websiteId,
|
||||
created_at: getDateFormat(new Date()),
|
||||
url: url?.substring(0, URL_LENGTH),
|
||||
referrer: referrer?.substring(0, URL_LENGTH),
|
||||
|
|
|
|||
|
|
@ -10,16 +10,16 @@ export async function createSession(...args) {
|
|||
});
|
||||
}
|
||||
|
||||
async function relationalQuery(website_id, data) {
|
||||
async function relationalQuery(websiteId, data) {
|
||||
return prisma.client.session
|
||||
.create({
|
||||
data: {
|
||||
website_id,
|
||||
websiteId,
|
||||
...data,
|
||||
},
|
||||
select: {
|
||||
session_id: true,
|
||||
session_uuid: true,
|
||||
sessionId: true,
|
||||
sessionUuid: true,
|
||||
hostname: true,
|
||||
browser: true,
|
||||
os: true,
|
||||
|
|
@ -31,7 +31,7 @@ async function relationalQuery(website_id, data) {
|
|||
})
|
||||
.then(async res => {
|
||||
if (redis.client && res) {
|
||||
await redis.client.set(`session:${res.session_uuid}`, res.session_id);
|
||||
await redis.client.set(`session:${res.sessionUuid}`, res.id);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
|
@ -39,14 +39,14 @@ async function relationalQuery(website_id, data) {
|
|||
}
|
||||
|
||||
async function clickhouseQuery(
|
||||
website_uuid,
|
||||
{ session_uuid, hostname, browser, os, screen, language, country, device },
|
||||
websiteId,
|
||||
{ sessionUuid, hostname, browser, os, screen, language, country, device },
|
||||
) {
|
||||
const { getDateFormat, sendMessage } = kafka;
|
||||
|
||||
const params = {
|
||||
session_uuid,
|
||||
website_uuid,
|
||||
session_uuid: sessionUuid,
|
||||
website_id: websiteId,
|
||||
created_at: getDateFormat(new Date()),
|
||||
hostname,
|
||||
browser,
|
||||
|
|
@ -60,6 +60,6 @@ async function clickhouseQuery(
|
|||
await sendMessage(params, 'event');
|
||||
|
||||
if (redis.client) {
|
||||
await redis.client.set(`session:${session_uuid}`, 1);
|
||||
await redis.client.set(`session:${sessionUuid}`, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,25 +10,25 @@ export async function getSessionByUuid(...args) {
|
|||
});
|
||||
}
|
||||
|
||||
async function relationalQuery(session_uuid) {
|
||||
async function relationalQuery(sessionUuid) {
|
||||
return prisma.client.session
|
||||
.findUnique({
|
||||
where: {
|
||||
session_uuid,
|
||||
sessionUuid,
|
||||
},
|
||||
})
|
||||
.then(async res => {
|
||||
if (redis.client && res) {
|
||||
await redis.client.set(`session:${res.session_uuid}`, res.session_id);
|
||||
await redis.client.set(`session:${res.sessionUuid}`, res.sessionId);
|
||||
}
|
||||
|
||||
return res;
|
||||
});
|
||||
}
|
||||
|
||||
async function clickhouseQuery(session_uuid) {
|
||||
async function clickhouseQuery(sessionUuid) {
|
||||
const { rawQuery, findFirst } = clickhouse;
|
||||
const params = [session_uuid];
|
||||
const params = [sessionUuid];
|
||||
|
||||
return rawQuery(
|
||||
`select distinct
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ export async function getSessionMetrics(...args) {
|
|||
});
|
||||
}
|
||||
|
||||
async function relationalQuery(website_id, { startDate, endDate, field, filters = {} }) {
|
||||
async function relationalQuery(websiteId, { startDate, endDate, field, filters = {} }) {
|
||||
const { parseFilters, rawQuery } = prisma;
|
||||
const params = [website_id, startDate, endDate];
|
||||
const params = [websiteId, startDate, endDate];
|
||||
const { pageviewQuery, sessionQuery, joinSession } = parseFilters(null, filters, params);
|
||||
|
||||
return rawQuery(
|
||||
|
|
@ -32,9 +32,9 @@ async function relationalQuery(website_id, { startDate, endDate, field, filters
|
|||
);
|
||||
}
|
||||
|
||||
async function clickhouseQuery(website_id, { startDate, endDate, field, filters = {} }) {
|
||||
async function clickhouseQuery(websiteId, { startDate, endDate, field, filters = {} }) {
|
||||
const { parseFilters, getBetweenDates, rawQuery } = clickhouse;
|
||||
const params = [website_id];
|
||||
const params = [websiteId];
|
||||
const { pageviewQuery, sessionQuery } = parseFilters(null, filters, params);
|
||||
|
||||
return rawQuery(
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ async function relationalQuery(websites, start_at) {
|
|||
...(websites && websites.length > 0
|
||||
? {
|
||||
website: {
|
||||
website_id: {
|
||||
id: {
|
||||
in: websites,
|
||||
},
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
created_at: {
|
||||
createdAt: {
|
||||
gte: start_at,
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ export async function getActiveVisitors(...args) {
|
|||
});
|
||||
}
|
||||
|
||||
async function relationalQuery(website_id) {
|
||||
async function relationalQuery(websiteId) {
|
||||
const date = subMinutes(new Date(), 5);
|
||||
const params = [website_id, date];
|
||||
const params = [websiteId, date];
|
||||
|
||||
return prisma.rawQuery(
|
||||
`select count(distinct session_id) x
|
||||
|
|
@ -23,9 +23,9 @@ async function relationalQuery(website_id) {
|
|||
);
|
||||
}
|
||||
|
||||
async function clickhouseQuery(website_uuid) {
|
||||
async function clickhouseQuery(websiteId) {
|
||||
const { rawQuery, getDateFormat } = clickhouse;
|
||||
const params = [website_uuid];
|
||||
const params = [websiteId];
|
||||
|
||||
return rawQuery(
|
||||
`select count(distinct session_id) x
|
||||
|
|
|
|||
|
|
@ -10,19 +10,19 @@ export async function getRealtimeData(websites, time) {
|
|||
]);
|
||||
|
||||
return {
|
||||
pageviews: pageviews.map(({ view_id, ...props }) => ({
|
||||
__id: `p${view_id}`,
|
||||
view_id,
|
||||
pageviews: pageviews.map(({ pageviewId, ...props }) => ({
|
||||
__id: `p${pageviewId}`,
|
||||
pageviewId,
|
||||
...props,
|
||||
})),
|
||||
sessions: sessions.map(({ session_id, ...props }) => ({
|
||||
__id: `s${session_id}`,
|
||||
session_id,
|
||||
sessions: sessions.map(({ sessionId, ...props }) => ({
|
||||
__id: `s${sessionId}`,
|
||||
sessionId,
|
||||
...props,
|
||||
})),
|
||||
events: events.map(({ event_id, ...props }) => ({
|
||||
__id: `e${event_id}`,
|
||||
event_id,
|
||||
events: events.map(({ eventId, ...props }) => ({
|
||||
__id: `e${eventId}`,
|
||||
eventId,
|
||||
...props,
|
||||
})),
|
||||
timestamp: Date.now(),
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ export async function getWebsiteStats(...args) {
|
|||
});
|
||||
}
|
||||
|
||||
async function relationalQuery(website_id, { start_at, end_at, filters = {} }) {
|
||||
async function relationalQuery(websiteId, { start_at, end_at, filters = {} }) {
|
||||
const { getDateQuery, getTimestampInterval, parseFilters, rawQuery } = prisma;
|
||||
const params = [website_id, start_at, end_at];
|
||||
const params = [websiteId, start_at, end_at];
|
||||
const { pageviewQuery, sessionQuery, joinSession } = parseFilters(
|
||||
'pageview',
|
||||
null,
|
||||
|
|
@ -41,9 +41,9 @@ async function relationalQuery(website_id, { start_at, end_at, filters = {} }) {
|
|||
);
|
||||
}
|
||||
|
||||
async function clickhouseQuery(website_uuid, { start_at, end_at, filters = {} }) {
|
||||
async function clickhouseQuery(websiteId, { start_at, end_at, filters = {} }) {
|
||||
const { rawQuery, getDateQuery, getBetweenDates, parseFilters } = clickhouse;
|
||||
const params = [website_uuid];
|
||||
const params = [websiteId];
|
||||
const { pageviewQuery, sessionQuery } = parseFilters(null, filters, params);
|
||||
|
||||
return rawQuery(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue