mirror of
https://github.com/umami-software/umami.git
synced 2026-02-11 08:07:12 +01:00
Added parseDateRangeQuery function.
This commit is contained in:
parent
09af33c77e
commit
1648707fc7
9 changed files with 48 additions and 80 deletions
|
|
@ -2,26 +2,26 @@ import clickhouse from 'lib/clickhouse';
|
|||
import { CLICKHOUSE, PRISMA, runQuery } from 'lib/db';
|
||||
import prisma from 'lib/prisma';
|
||||
|
||||
export function getEvents(...args: [websiteId: string, startAt: Date, eventType: number]) {
|
||||
export function getEvents(...args: [websiteId: string, startDate: Date, eventType: number]) {
|
||||
return runQuery({
|
||||
[PRISMA]: () => relationalQuery(...args),
|
||||
[CLICKHOUSE]: () => clickhouseQuery(...args),
|
||||
});
|
||||
}
|
||||
|
||||
function relationalQuery(websiteId: string, startAt: Date, eventType: number) {
|
||||
function relationalQuery(websiteId: string, startDate: Date, eventType: number) {
|
||||
return prisma.client.websiteEvent.findMany({
|
||||
where: {
|
||||
websiteId,
|
||||
eventType,
|
||||
createdAt: {
|
||||
gte: startAt,
|
||||
gte: startDate,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function clickhouseQuery(websiteId: string, startAt: Date, eventType: number) {
|
||||
function clickhouseQuery(websiteId: string, startDate: Date, eventType: number) {
|
||||
const { rawQuery } = clickhouse;
|
||||
|
||||
return rawQuery(
|
||||
|
|
@ -37,12 +37,12 @@ function clickhouseQuery(websiteId: string, startAt: Date, eventType: number) {
|
|||
event_name as eventName
|
||||
from website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at >= {startAt:DateTime}
|
||||
and created_at >= {startDate:DateTime}
|
||||
and event_type = {eventType:UInt32}
|
||||
`,
|
||||
{
|
||||
websiteId,
|
||||
startAt,
|
||||
startDate,
|
||||
eventType,
|
||||
},
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue