mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 22:57:12 +01:00
Show active visitor count.
This commit is contained in:
parent
9f6e17b986
commit
b96cb0d975
14 changed files with 158 additions and 35 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import moment from 'moment-timezone';
|
||||
import prisma, { runQuery } from 'lib/db';
|
||||
import { subMinutes } from 'date-fns';
|
||||
|
||||
const POSTGRESQL = 'postgresql';
|
||||
const MYSQL = 'mysql';
|
||||
|
|
@ -366,3 +367,16 @@ export function getRankings(website_id, start_at, end_at, type, table) {
|
|||
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
export function getActiveVisitors(website_id) {
|
||||
return prisma.$queryRaw(
|
||||
`
|
||||
select count(distinct session_id) x
|
||||
from pageview
|
||||
where website_id=$1
|
||||
and created_at >= $2
|
||||
`,
|
||||
website_id,
|
||||
subMinutes(new Date(), 5),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue