Upgrade prisma. Lint fixes.

This commit is contained in:
Mike Cao 2023-11-30 21:58:11 -08:00
parent a3b5f05a32
commit a224a3caf3
11 changed files with 56 additions and 51 deletions

View file

@ -45,7 +45,7 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {
async function clickhouseQuery(
websiteId: string,
filters: QueryFilters,
): Promise<{ events: number; fields: number; records: number }> {
): Promise<{ events: number; fields: number; records: number }[]> {
const { rawQuery, parseFilters } = clickhouse;
const { filterQuery, params } = await parseFilters(websiteId, filters);

View file

@ -2,15 +2,15 @@ import { md5 } from 'next-basics';
import { getSessions, getEvents } from 'queries/index';
import { EVENT_TYPE } from 'lib/constants';
export async function getRealtimeData(websiteId, time) {
export async function getRealtimeData(websiteId: string, startDate: Date) {
const [pageviews, sessions, events] = await Promise.all([
getEvents(websiteId, time, EVENT_TYPE.pageView),
getSessions(websiteId, time),
getEvents(websiteId, time, EVENT_TYPE.customEvent),
getEvents(websiteId, startDate, EVENT_TYPE.pageView),
getSessions(websiteId, startDate),
getEvents(websiteId, startDate, EVENT_TYPE.customEvent),
]);
const decorate = (id, data) => {
return data.map(props => ({
const decorate = (id: string, data: any[]) => {
return data.map((props: { [key: string]: any }) => ({
...props,
__id: md5(id, ...Object.values(props)),
__type: id,

View file

@ -83,10 +83,17 @@ async function clickhouseQuery(
limit 500
`,
params,
);
).then(a => {
return Object.values(a).map(a => {
return {
x: a.x,
y: Number(a.y),
};
});
});
}
function parseFields(fields) {
function parseFields(fields: any[]) {
const query = fields.reduce(
(arr, field) => {
const { name } = field;
@ -99,7 +106,7 @@ function parseFields(fields) {
return query.join(',\n');
}
function parseGroupBy(fields) {
function parseGroupBy(fields: { name: any }[]) {
if (!fields.length) {
return '';
}