mirror of
https://github.com/umami-software/umami.git
synced 2026-02-05 05:07:15 +01:00
Fixed search for postgresql.
This commit is contained in:
parent
e6aebf5104
commit
91efb7f1d0
4 changed files with 30 additions and 40 deletions
|
|
@ -97,7 +97,7 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
|
|||
// eslint-disable-next-line prefer-const
|
||||
let [urlPath, urlQuery] = url?.split('?') || [];
|
||||
let [referrerPath, referrerQuery] = referrer?.split('?') || [];
|
||||
let referrerDomain;
|
||||
let referrerDomain = '';
|
||||
|
||||
if (!urlPath) {
|
||||
urlPath = '/';
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { badRequest, methodNotAllowed, ok, unauthorized } from 'next-basics';
|
|||
import { WebsiteMetric, NextApiRequestQueryBody } from 'lib/types';
|
||||
import { canViewWebsite } from 'lib/auth';
|
||||
import { useAuth, useCors, useValidate } from 'lib/middleware';
|
||||
import { SESSION_COLUMNS, EVENT_COLUMNS, FILTER_COLUMNS } from 'lib/constants';
|
||||
import { SESSION_COLUMNS, EVENT_COLUMNS, FILTER_COLUMNS, OPERATORS } from 'lib/constants';
|
||||
import { getPageviewMetrics, getSessionMetrics } from 'queries';
|
||||
import { parseDateRangeQuery } from 'lib/query';
|
||||
import * as yup from 'yup';
|
||||
|
|
@ -88,7 +88,7 @@ export default async (
|
|||
}
|
||||
|
||||
const { startDate, endDate } = await parseDateRangeQuery(req);
|
||||
|
||||
const column = FILTER_COLUMNS[type] || type;
|
||||
const filters = {
|
||||
startDate,
|
||||
endDate,
|
||||
|
|
@ -104,19 +104,18 @@ export default async (
|
|||
city,
|
||||
language,
|
||||
event,
|
||||
search,
|
||||
};
|
||||
|
||||
const column = FILTER_COLUMNS[type] || type;
|
||||
if (search) {
|
||||
filters[column] = {
|
||||
column,
|
||||
op: OPERATORS.contains,
|
||||
value: '%' + search + '%',
|
||||
};
|
||||
}
|
||||
|
||||
if (SESSION_COLUMNS.includes(type)) {
|
||||
const data = await getSessionMetrics(
|
||||
websiteId,
|
||||
column,
|
||||
{ ...filters, search },
|
||||
limit,
|
||||
offset,
|
||||
);
|
||||
const data = await getSessionMetrics(websiteId, column, filters, limit, offset);
|
||||
|
||||
if (type === 'language') {
|
||||
const combined = {};
|
||||
|
|
@ -138,13 +137,7 @@ export default async (
|
|||
}
|
||||
|
||||
if (EVENT_COLUMNS.includes(type)) {
|
||||
const data = await getPageviewMetrics(
|
||||
websiteId,
|
||||
column,
|
||||
{ ...filters, search },
|
||||
limit,
|
||||
offset,
|
||||
);
|
||||
const data = await getPageviewMetrics(websiteId, column, filters, limit, offset);
|
||||
|
||||
return ok(res, data);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue