Fixed query parameter filter.

This commit is contained in:
Mike Cao 2023-03-30 09:44:04 -07:00
parent 358519dddd
commit 64b040c865
3 changed files with 5 additions and 4 deletions

View File

@ -190,8 +190,8 @@ function parseFilters(filters: any = {}, params: any = {}) {
async function rawQuery(query, params = {}) {
if (process.env.LOG_QUERY) {
log(query);
log(params);
log('QUERY:\n', query);
log('PARAMETERS:\n', params);
}
await connect();

View File

@ -50,7 +50,7 @@ export const percentFilter = data => {
export const paramFilter = data => {
const map = data.reduce((obj, { x, y }) => {
try {
const searchParams = new URLSearchParams(x.split('?')[1]);
const searchParams = new URLSearchParams(x);
for (const [key, value] of searchParams) {
if (!obj[key]) {

View File

@ -89,6 +89,7 @@ export default async (
subdivision1,
subdivision2,
city,
query,
} = req.query;
if (req.method === 'GET') {
@ -162,7 +163,7 @@ export default async (
subdivision2: type !== 'subdivision2' ? subdivision2 : undefined,
city: type !== 'city' ? city : undefined,
eventUrl: type !== 'url' && table === 'event' ? url : undefined,
query: type === 'query' && table !== 'event' ? true : undefined,
query: type !== 'query' && table !== 'event' ? query : undefined,
};
const data = await getPageviewMetrics(websiteId, {