mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 15:17:23 +01:00
fix UTC issues
This commit is contained in:
parent
004ccdc22f
commit
a15d0ca94a
6 changed files with 35 additions and 21 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { getRealtimeActivity, getPageviewStats, getSessionStats } from 'queries/index';
|
||||
import { getPageviewStats, getRealtimeActivity, getSessionStats } from 'queries/index';
|
||||
|
||||
function increment(data: object, key: string) {
|
||||
if (key) {
|
||||
|
|
@ -10,9 +10,12 @@ function increment(data: object, key: string) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function getRealtimeData(websiteId: string, criteria: { startDate: Date }) {
|
||||
const { startDate } = criteria;
|
||||
const filters = { startDate, endDate: new Date(), unit: 'minute' };
|
||||
export async function getRealtimeData(
|
||||
websiteId: string,
|
||||
criteria: { startDate: Date; timezone: string },
|
||||
) {
|
||||
const { startDate, timezone } = criteria;
|
||||
const filters = { startDate, endDate: new Date(), unit: 'minute', timezone };
|
||||
const [activity, pageviews, sessions] = await Promise.all([
|
||||
getRealtimeActivity(websiteId, filters),
|
||||
getPageviewStats(websiteId, filters),
|
||||
|
|
|
|||
|
|
@ -13,13 +13,14 @@ export async function getWebsiteSessionsWeekly(
|
|||
}
|
||||
|
||||
async function relationalQuery(websiteId: string, filters: QueryFilters) {
|
||||
const { timezone = 'utc' } = filters;
|
||||
const { rawQuery, getDateWeeklySQL, parseFilters } = prisma;
|
||||
const { params } = await parseFilters(websiteId, filters);
|
||||
|
||||
return rawQuery(
|
||||
`
|
||||
select
|
||||
${getDateWeeklySQL('created_at')} as time,
|
||||
${getDateWeeklySQL('created_at', timezone)} as time,
|
||||
count(distinct session_id) as value
|
||||
from website_event
|
||||
where website_id = {{websiteId::uuid}}
|
||||
|
|
@ -32,13 +33,14 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {
|
|||
}
|
||||
|
||||
async function clickhouseQuery(websiteId: string, filters: QueryFilters) {
|
||||
const { timezone = 'utc' } = filters;
|
||||
const { rawQuery } = clickhouse;
|
||||
const { startDate, endDate } = filters;
|
||||
|
||||
return rawQuery(
|
||||
`
|
||||
select
|
||||
formatDateTime(created_at, '%w:%H') as time,
|
||||
formatDateTime(toDateTime(created_at, '${timezone}'), '%w:%H') as time,
|
||||
count(distinct session_id) as value
|
||||
from website_event_stats_hourly
|
||||
where website_id = {websiteId:UUID}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue