Updated data query limits.

This commit is contained in:
Mike Cao 2024-08-17 20:27:40 -07:00
parent b6b1488ddf
commit ffa954ee02
4 changed files with 13 additions and 5 deletions

View File

@ -189,7 +189,7 @@ async function rawQuery<T = unknown>(
format: 'JSONEachRow', format: 'JSONEachRow',
}); });
return resultSet.json() as T; return (await resultSet.json()) as T;
} }
async function insert(table: string, values: any[]) { async function insert(table: string, values: any[]) {

View File

@ -1,3 +1,4 @@
import debug from 'debug';
import { Prisma } from '@prisma/client'; import { Prisma } from '@prisma/client';
import prisma from '@umami/prisma-client'; import prisma from '@umami/prisma-client';
import moment from 'moment-timezone'; import moment from 'moment-timezone';
@ -8,6 +9,8 @@ import { maxDate } from './date';
import { QueryFilters, QueryOptions, PageParams } from './types'; import { QueryFilters, QueryOptions, PageParams } from './types';
import { filtersToArray } from './params'; import { filtersToArray } from './params';
const log = debug('umami:prisma');
const MYSQL_DATE_FORMATS = { const MYSQL_DATE_FORMATS = {
minute: '%Y-%m-%d %H:%i:00', minute: '%Y-%m-%d %H:%i:00',
hour: '%Y-%m-%d %H:00:00', hour: '%Y-%m-%d %H:00:00',
@ -210,6 +213,11 @@ async function parseFilters(
} }
async function rawQuery(sql: string, data: object): Promise<any> { async function rawQuery(sql: string, data: object): Promise<any> {
if (process.env.LOG_QUERY) {
log('QUERY:\n', sql);
log('PARAMETERS:\n', data);
}
const db = getDatabaseType(); const db = getDatabaseType();
const params = []; const params = [];

View File

@ -35,7 +35,7 @@ async function relationalQuery(
${filterQuery} ${filterQuery}
group by string_value group by string_value
order by 2 desc order by 2 desc
limit 500 limit 100
`, `,
params, params,
); );
@ -63,7 +63,7 @@ async function clickhouseQuery(
${filterQuery} ${filterQuery}
group by event_name, value group by event_name, value
order by 2 desc order by 2 desc
limit 500; limit 100
`, `,
params, params,
).then(result => { ).then(result => {

View File

@ -31,7 +31,7 @@ async function relationalQuery(
${filterQuery} ${filterQuery}
group by string_value group by string_value
order by 2 desc order by 2 desc
limit 500 limit 100
`, `,
params, params,
); );
@ -58,7 +58,7 @@ async function clickhouseQuery(
${filterQuery} ${filterQuery}
group by value group by value
order by 2 desc order by 2 desc
limit 500; limit 100
`, `,
params, params,
).then(result => { ).then(result => {