Skip to content

Commit

Permalink
Refactoring PR344
Browse files Browse the repository at this point in the history
  • Loading branch information
tilfin committed Oct 26, 2024
1 parent 716ad12 commit 82a4523
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/js/lib/target_profiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function retrieveTargetProfilesFromDB(ctx) {
const complexTargetItems = await dbTable.query(`${matchedComplexSrc.name};`);
let targets = complexTargetItems.map(it => convertComplexTarget(it, matchedComplexSrc));
if (filterByTargetRole) {
targets = targets.filter(it => targetRoleNameMatches(it, filterByTargetRole));
targets = targets.filter(it => isRoleNameLeafMatch(it, filterByTargetRole));
}
results.push(...targets)
}
Expand Down Expand Up @@ -72,14 +72,14 @@ async function retrieveTargetProfilesFromLztext(ctx) {
if (matchedComplexSrc) {
let targets = matchedComplexSrc.targets;
if (filterByTargetRole) {
targets = targets.filter(it => targetRoleNameMatches(it, filterByTargetRole));
targets = targets.filter(it => isRoleNameLeafMatch(it, filterByTargetRole));
}
results.push(...targets)
}

return results;
}

function targetRoleNameMatches(it, filterByTargetRole) {
return it.role_name === filterByTargetRole || it.role_name.substring(it.role_name.lastIndexOf('/') + 1) === filterByTargetRole;
function isRoleNameLeafMatch(item, targetLeaf) {
return item.role_name.split('/').pop() === targetLeaf;
}

0 comments on commit 82a4523

Please sign in to comment.