Skip to content

Commit

Permalink
Refactored src/flags.js getFlagIdsWithFilters
Browse files Browse the repository at this point in the history
  • Loading branch information
Kayla Lei authored and Kayla Lei committed Sep 16, 2024
1 parent 26adcab commit 5f0098c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Binary file added dump.rdb
Binary file not shown.
16 changes: 11 additions & 5 deletions src/flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ Flags.getCount = async function ({ uid, filters, query }) {
return flagIds.length;
};

function applyFlagFilters(type, sets, orSets, filters, uid) {
if (Flags._filters.hasOwnProperty(type)) {
Flags._filters[type](sets, orSets, filters[type], uid);
} else {
winston.warn(`[flags/list] No flag filter type found: ${type}`);
}
}

Flags.getFlagIdsWithFilters = async function ({ filters, uid, query }) {
let sets = [];
const orSets = [];
Expand All @@ -143,12 +151,10 @@ Flags.getFlagIdsWithFilters = async function ({ filters, uid, query }) {
filters.perPage = filters.hasOwnProperty('perPage') ? Math.abs(parseInt(filters.perPage, 10) || 20) : 20;

for (const type of Object.keys(filters)) {
if (Flags._filters.hasOwnProperty(type)) {
Flags._filters[type](sets, orSets, filters[type], uid);
} else {
winston.warn(`[flags/list] No flag filter type found: ${type}`);
}
applyFlagFilters(type, sets, orSets, filters, uid);
}
console.log('KAYLA_LEI');

sets = (sets.length || orSets.length) ? sets : ['flags:datetime']; // No filter default

let flagIds = [];
Expand Down

0 comments on commit 5f0098c

Please sign in to comment.