mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 14:17:13 +01:00
Merge branch 'dev' into analytics
# Conflicts: # src/app/(main)/reports/[id]/Report.js # src/queries/analytics/eventData/getEventDataEvents.ts # src/queries/analytics/getActiveVisitors.ts # src/queries/analytics/sessions/getSessionMetrics.ts # yarn.lock
This commit is contained in:
commit
fc1f2c9cd3
380 changed files with 4193 additions and 4686 deletions
|
|
@ -8,7 +8,11 @@ export function getEventUsage(...args: [websiteIds: string[], startDate: Date, e
|
|||
});
|
||||
}
|
||||
|
||||
function clickhouseQuery(websiteIds: string[], startDate: Date, endDate: Date) {
|
||||
function clickhouseQuery(
|
||||
websiteIds: string[],
|
||||
startDate: Date,
|
||||
endDate: Date,
|
||||
): Promise<{ websiteId: string; count: number }[]> {
|
||||
const { rawQuery } = clickhouse;
|
||||
|
||||
return rawQuery(
|
||||
|
|
@ -26,5 +30,9 @@ function clickhouseQuery(websiteIds: string[], startDate: Date, endDate: Date) {
|
|||
startDate,
|
||||
endDate,
|
||||
},
|
||||
);
|
||||
).then(a => {
|
||||
return Object.values(a).map(a => {
|
||||
return { websiteId: a.websiteId, count: Number(a.count) };
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,16 @@ import prisma from 'lib/prisma';
|
|||
import clickhouse from 'lib/clickhouse';
|
||||
import { runQuery, CLICKHOUSE, PRISMA } from 'lib/db';
|
||||
|
||||
export async function getValues(...args: [websiteId: string, column: string]) {
|
||||
export async function getValues(
|
||||
...args: [websiteId: string, column: string, startDate: Date, endDate: Date]
|
||||
) {
|
||||
return runQuery({
|
||||
[PRISMA]: () => relationalQuery(...args),
|
||||
[CLICKHOUSE]: () => clickhouseQuery(...args),
|
||||
});
|
||||
}
|
||||
|
||||
async function relationalQuery(websiteId: string, column: string) {
|
||||
async function relationalQuery(websiteId: string, column: string, startDate: Date, endDate: Date) {
|
||||
const { rawQuery } = prisma;
|
||||
|
||||
return rawQuery(
|
||||
|
|
@ -19,12 +21,18 @@ async function relationalQuery(websiteId: string, column: string) {
|
|||
inner join session
|
||||
on session.session_id = website_event.session_id
|
||||
where website_event.website_id = {{websiteId::uuid}}
|
||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||
limit 100
|
||||
`,
|
||||
{ websiteId },
|
||||
{
|
||||
websiteId,
|
||||
startDate,
|
||||
endDate,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
async function clickhouseQuery(websiteId: string, column: string) {
|
||||
async function clickhouseQuery(websiteId: string, column: string, startDate: Date, endDate: Date) {
|
||||
const { rawQuery } = clickhouse;
|
||||
|
||||
return rawQuery(
|
||||
|
|
@ -32,7 +40,13 @@ async function clickhouseQuery(websiteId: string, column: string) {
|
|||
select distinct ${column} as value
|
||||
from website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
limit 100
|
||||
`,
|
||||
{ websiteId },
|
||||
{
|
||||
websiteId,
|
||||
startDate,
|
||||
endDate,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ export async function getRetention(
|
|||
filters: {
|
||||
startDate: Date;
|
||||
endDate: Date;
|
||||
timezone: string;
|
||||
timezone?: string;
|
||||
},
|
||||
]
|
||||
) {
|
||||
|
|
@ -23,7 +23,7 @@ async function relationalQuery(
|
|||
filters: {
|
||||
startDate: Date;
|
||||
endDate: Date;
|
||||
timezone: string;
|
||||
timezone?: string;
|
||||
},
|
||||
): Promise<
|
||||
{
|
||||
|
|
@ -103,7 +103,7 @@ async function clickhouseQuery(
|
|||
filters: {
|
||||
startDate: Date;
|
||||
endDate: Date;
|
||||
timezone: string;
|
||||
timezone?: string;
|
||||
},
|
||||
): Promise<
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue