mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 22:57:12 +01:00
update CH rawquery and type
This commit is contained in:
parent
d13f0bc5fe
commit
e2bb2defd4
17 changed files with 169 additions and 52 deletions
|
|
@ -24,17 +24,23 @@ async function relationalQuery(websiteId: string) {
|
|||
);
|
||||
}
|
||||
|
||||
async function clickhouseQuery(websiteId: string) {
|
||||
async function clickhouseQuery(websiteId: string): Promise<{ x: number }> {
|
||||
const { rawQuery } = clickhouse;
|
||||
|
||||
return rawQuery(
|
||||
const result = rawQuery(
|
||||
`
|
||||
select
|
||||
count(distinct session_id) x
|
||||
from website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at >= {startAt:DateTime}
|
||||
and created_at >= {startAt:DateTime64}
|
||||
`,
|
||||
{ websiteId, startAt: subMinutes(new Date(), 5) },
|
||||
);
|
||||
).then(a => {
|
||||
return Object.values(a).map(a => {
|
||||
return { x: Number(a.x) };
|
||||
});
|
||||
});
|
||||
|
||||
return result[0] ?? null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue