Upgraded next and prisma. Replaced moment-timezone.

This commit is contained in:
Mike Cao 2024-11-22 04:04:13 -08:00
parent 620a838173
commit fccb1ddd9a
7 changed files with 3036 additions and 160 deletions

View file

@ -1,7 +1,7 @@
import debug from 'debug';
import { Prisma } from '@prisma/client';
import prisma from '@umami/prisma-client';
import moment from 'moment-timezone';
import { formatInTimeZone } from 'date-fns-tz';
import { MYSQL, POSTGRESQL, getDatabaseType } from 'lib/db';
import { SESSION_COLUMNS, OPERATORS, DEFAULT_PAGE_SIZE } from './constants';
import { fetchWebsite } from './load';
@ -75,7 +75,7 @@ function getDateSQL(field: string, unit: string, timezone?: string): string {
if (db === MYSQL) {
if (timezone) {
const tz = moment.tz(timezone).format('Z');
const tz = formatInTimeZone(new Date(), timezone, 'yyyy-MM-dd HH:mm:ss');
return `date_format(convert_tz(${field},'+00:00','${tz}'), '${MYSQL_DATE_FORMATS[unit]}')`;
}
return `date_format(${field}, '${MYSQL_DATE_FORMATS[unit]}')`;
@ -90,7 +90,7 @@ function getDateWeeklySQL(field: string, timezone?: string) {
}
if (db === MYSQL) {
const tz = moment.tz(timezone).format('Z');
const tz = formatInTimeZone(new Date(), timezone, 'yyyy-MM-dd HH:mm:ss');
return `date_format(convert_tz(${field},'+00:00','${tz}'), '%w:%H')`;
}
}