mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 17:55:08 +01:00
29 lines
558 B
JavaScript
29 lines
558 B
JavaScript
import { getDateQuery, getFilterQuery, rawQuery } from 'lib/queries';
|
|
|
|
export function getEventMetrics(
|
|
website_id,
|
|
start_at,
|
|
end_at,
|
|
timezone = 'utc',
|
|
unit = 'day',
|
|
filters = {},
|
|
) {
|
|
const params = [website_id, start_at, end_at];
|
|
|
|
return rawQuery(
|
|
`
|
|
select
|
|
event_value x,
|
|
${getDateQuery('created_at', unit, timezone)} 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,
|
|
);
|
|
}
|