diff --git a/lib/queries.js b/lib/queries.js index ffbb6655..3a62a37f 100644 --- a/lib/queries.js +++ b/lib/queries.js @@ -64,9 +64,10 @@ export function getFilterQuery(table, filters = {}, params = []) { switch (key) { case 'url': - if (table === 'session' || table === 'pageview') { - arr.push(`and ${table}.${key}=$${params.length + 1}`); + if (table === 'session' || table === 'pageview' || table === 'event') { + arr.push(`and (${table}.${key}=$${params.length + 1} or ${table}.${key} like $${params.length + 2})`); params.push(decodeURIComponent(value)); + params.push(`${decodeURIComponent(value)}?%`); } break; @@ -125,7 +126,7 @@ export function parseFilters(table, filters = {}, params = []) { os || browser || device || country ? `inner join session on ${table}.session_id = session.session_id` : '', - pageviewQuery: getFilterQuery('pageview', pageviewFilters, params), + pageviewQuery: table === 'event' ? getFilterQuery('event', pageviewFilters, params) : getFilterQuery('pageview', pageviewFilters, params), sessionQuery: getFilterQuery('session', sessionFilters, params), eventQuery: getFilterQuery('event', eventFilters, params), };