mirror of
https://github.com/umami-software/umami.git
synced 2026-02-11 08:07:12 +01:00
Updated filtering logic.
This commit is contained in:
parent
112005212e
commit
9d86385f5c
8 changed files with 23 additions and 31 deletions
|
|
@ -3,7 +3,7 @@ import dateFormat from 'dateformat';
|
|||
import debug from 'debug';
|
||||
import { CLICKHOUSE } from 'lib/db';
|
||||
import { QueryFilters } from './types';
|
||||
import { FILTER_COLUMNS, IGNORED_FILTERS } from './constants';
|
||||
import { FILTER_COLUMNS } from './constants';
|
||||
import { loadWebsite } from './load';
|
||||
import { maxDate } from './date';
|
||||
|
||||
|
|
@ -66,9 +66,9 @@ function getDateFormat(date) {
|
|||
function getFilterQuery(filters = {}) {
|
||||
const query = Object.keys(filters).reduce((arr, key) => {
|
||||
const filter = filters[key];
|
||||
const column = FILTER_COLUMNS[key];
|
||||
|
||||
if (filter !== undefined && !IGNORED_FILTERS.includes(key)) {
|
||||
const column = FILTER_COLUMNS[key] || key;
|
||||
if (filter !== undefined && column) {
|
||||
arr.push(`and ${column} = {${key}:String}`);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,23 +48,16 @@ export const FILTER_COLUMNS = {
|
|||
referrer: 'referrer_domain',
|
||||
title: 'page_title',
|
||||
query: 'url_query',
|
||||
os: 'os',
|
||||
browser: 'browser',
|
||||
device: 'device',
|
||||
country: 'country',
|
||||
region: 'subdivision1',
|
||||
eventType: 'event_type',
|
||||
eventName: 'event_name',
|
||||
city: 'city',
|
||||
language: 'language',
|
||||
event: 'event_name',
|
||||
};
|
||||
|
||||
export const IGNORED_FILTERS = [
|
||||
'startDate',
|
||||
'endDate',
|
||||
'timezone',
|
||||
'unit',
|
||||
'eventType',
|
||||
'fields',
|
||||
'filters',
|
||||
'groups',
|
||||
];
|
||||
|
||||
export const COLLECTION_TYPE = {
|
||||
event: 'event',
|
||||
identify: 'identify',
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import prisma from '@umami/prisma-client';
|
||||
import moment from 'moment-timezone';
|
||||
import { MYSQL, POSTGRESQL, getDatabaseType } from 'lib/db';
|
||||
import { FILTER_COLUMNS, IGNORED_FILTERS, SESSION_COLUMNS } from './constants';
|
||||
import { FILTER_COLUMNS, SESSION_COLUMNS } from './constants';
|
||||
import { loadWebsite } from './load';
|
||||
import { maxDate } from './date';
|
||||
import { QueryFilters, QueryOptions } from './types';
|
||||
|
|
@ -70,9 +70,9 @@ function getTimestampIntervalQuery(field: string): string {
|
|||
function getFilterQuery(filters = {}): string {
|
||||
const query = Object.keys(filters).reduce((arr, key) => {
|
||||
const filter = filters[key];
|
||||
const column = FILTER_COLUMNS[key];
|
||||
|
||||
if (filter !== undefined && !IGNORED_FILTERS.includes(key)) {
|
||||
const column = FILTER_COLUMNS[key] || key;
|
||||
if (filter !== undefined && column) {
|
||||
arr.push(`and ${column}={{${key}}}`);
|
||||
|
||||
if (key === 'referrer') {
|
||||
|
|
|
|||
|
|
@ -135,9 +135,7 @@ export interface QueryFilters {
|
|||
endDate?: Date;
|
||||
timezone?: string;
|
||||
unit?: string;
|
||||
domain?: string;
|
||||
eventType?: number;
|
||||
eventName?: string;
|
||||
url?: string;
|
||||
referrer?: string;
|
||||
title?: string;
|
||||
|
|
@ -149,6 +147,7 @@ export interface QueryFilters {
|
|||
region?: string;
|
||||
city?: string;
|
||||
language?: string;
|
||||
event?: string;
|
||||
}
|
||||
|
||||
export interface QueryOptions {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue