Skip to content

Commit

Permalink
Perf: improve performance of filterAndOrderOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
OlimpiaZurek committed Jan 30, 2025
1 parent a32c86b commit 54071b4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2050,7 +2050,15 @@ function filterAndOrderOptions(options: Options, searchInputValue: string, confi
const orderedOptions = combineOrderingOfReportsAndPersonalDetails(filterResult, searchInputValue, config);

// on staging server, in specific cases (see issue) BE returns duplicated personalDetails entries
orderedOptions.personalDetails = orderedOptions.personalDetails.filter((detail, index, array) => array.findIndex((i) => i.login === detail.login) === index);
const uniqueLogins = new Set<string>();
orderedOptions.personalDetails = orderedOptions.personalDetails.filter((detail) => {
const login = detail.login ?? '';
if (uniqueLogins.has(login)) {
return false;
}
uniqueLogins.add(login);
return true;
});

return {
...filterResult,
Expand Down

0 comments on commit 54071b4

Please sign in to comment.