mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-16 02:05:04 +01:00
27 lines
634 B
JavaScript
27 lines
634 B
JavaScript
import { parseFilters, rawQuery } from 'lib/queries';
|
|
|
|
export function getPageviewMetrics(website_id, start_at, end_at, field, table, filters = {}) {
|
|
const params = [website_id, start_at, end_at];
|
|
const { pageviewQuery, sessionQuery, eventQuery, joinSession } = parseFilters(
|
|
table,
|
|
filters,
|
|
params,
|
|
);
|
|
|
|
return rawQuery(
|
|
`
|
|
select ${field} x, count(*) y
|
|
from ${table}
|
|
${joinSession}
|
|
where ${table}.website_id=$1
|
|
and ${table}.created_at between $2 and $3
|
|
${pageviewQuery}
|
|
${joinSession && sessionQuery}
|
|
${eventQuery}
|
|
group by 1
|
|
order by 2 desc
|
|
`,
|
|
params,
|
|
);
|
|
}
|