mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 15:47:13 +01:00
checkpoint
This commit is contained in:
parent
cef365bb55
commit
20b8337e35
34 changed files with 620 additions and 222 deletions
|
|
@ -1,6 +1,17 @@
|
|||
import { getDateQuery, getDateStringQuery, getFilterQuery, rawQuery } from 'lib/queries';
|
||||
import {
|
||||
getDateQuery,
|
||||
getDateStringQuery,
|
||||
getFilterQuery,
|
||||
rawQuery,
|
||||
runAnalyticsQuery,
|
||||
clickhouse,
|
||||
} from 'lib/db';
|
||||
|
||||
export function getEventMetrics(
|
||||
export function getEventMetrics(...args) {
|
||||
return runAnalyticsQuery(relationalQuery(...args), clickhouseQuery(...args));
|
||||
}
|
||||
|
||||
function relationalQuery(
|
||||
website_id,
|
||||
start_at,
|
||||
end_at,
|
||||
|
|
@ -26,3 +37,30 @@ export function getEventMetrics(
|
|||
params,
|
||||
);
|
||||
}
|
||||
|
||||
function clickhouseQuery(
|
||||
website_id,
|
||||
start_at,
|
||||
end_at,
|
||||
timezone = 'utc',
|
||||
unit = 'day',
|
||||
filters = {},
|
||||
) {
|
||||
const params = [website_id, start_at, end_at];
|
||||
|
||||
return clickhouse.query(
|
||||
`
|
||||
select
|
||||
event_value x,
|
||||
${getDateStringQuery(getDateQuery('created_at', unit, timezone), unit)} t,
|
||||
count(*) y
|
||||
from event
|
||||
where website_id=$1
|
||||
and created_at between $2 and $3
|
||||
${getFilterQuery('event', filters, params)}
|
||||
group by 1, 2
|
||||
order by 2
|
||||
`,
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { runQuery } from 'lib/queries';
|
||||
import prisma from 'lib/db';
|
||||
import { prisma, runQuery } from 'lib/db';
|
||||
|
||||
export async function getEvents(websites, start_at) {
|
||||
return runQuery(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { runQuery } from 'lib/queries';
|
||||
import prisma from 'lib/db';
|
||||
import { prisma, runQuery } from 'lib/db';
|
||||
|
||||
import { URL_LENGTH } from 'lib/constants';
|
||||
|
||||
export async function saveEvent(website_id, session_id, url, event_type, event_value) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue