Skip to content

Commit

Permalink
merge src/flags.js changes from p1
Browse files Browse the repository at this point in the history
  • Loading branch information
Kayla Lei committed Sep 17, 2024
1 parent f6d9d89 commit 7c73e58
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 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,11 +151,7 @@ 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);
}
sets = (sets.length || orSets.length) ? sets : ['flags:datetime']; // No filter default

Expand Down

0 comments on commit 7c73e58

Please sign in to comment.