mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 17:55:08 +01:00
18 lines
366 B
JavaScript
18 lines
366 B
JavaScript
import { rawQuery } from 'lib/queries';
|
|
import { subMinutes } from 'date-fns';
|
|
|
|
export function getActiveVisitors(website_id) {
|
|
const date = subMinutes(new Date(), 5);
|
|
const params = [website_id, date];
|
|
|
|
return rawQuery(
|
|
`
|
|
select count(distinct session_id) x
|
|
from pageview
|
|
where website_id=$1
|
|
and created_at >= $2
|
|
`,
|
|
params,
|
|
);
|
|
}
|