mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 15:17:23 +01:00
Refactored functionality for all time date range.
This commit is contained in:
parent
c3973f5fb5
commit
d06808985b
11 changed files with 91 additions and 33 deletions
|
|
@ -16,32 +16,36 @@ async function relationalQuery(websiteId: string) {
|
|||
const { rawQuery } = prisma;
|
||||
const website = await loadWebsite(websiteId);
|
||||
|
||||
return rawQuery(
|
||||
const result = await rawQuery(
|
||||
`
|
||||
select
|
||||
min(created_at) as min,
|
||||
max(created_at) as max
|
||||
min(created_at) as mindate,
|
||||
max(created_at) as maxdate
|
||||
from website_event
|
||||
where website_id = {{websiteId::uuid}}
|
||||
and created_at >= {{startDate}}
|
||||
`,
|
||||
{ websiteId, startDate: maxDate(new Date(DEFAULT_RESET_DATE), new Date(website.resetAt)) },
|
||||
);
|
||||
|
||||
return result[0] ?? null;
|
||||
}
|
||||
|
||||
async function clickhouseQuery(websiteId: string) {
|
||||
const { rawQuery } = clickhouse;
|
||||
const website = await loadWebsite(websiteId);
|
||||
|
||||
return rawQuery(
|
||||
const result = await rawQuery(
|
||||
`
|
||||
select
|
||||
min(created_at) as min,
|
||||
max(created_at) as max
|
||||
min(created_at) as mindate,
|
||||
max(created_at) as maxdate
|
||||
from website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at >= {startDate:DateTime}
|
||||
`,
|
||||
{ websiteId, startDate: maxDate(new Date(DEFAULT_RESET_DATE), new Date(website.resetAt)) },
|
||||
);
|
||||
|
||||
return result[0] ?? null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue