Skip to content

fix(ENG-11334): preserve cedar_roperty_iri on api filter key collision#1012

Open
Vlad0n20 wants to merge 2 commits into
CenterForOpenScience:feature/es2-consolidationfrom
Vlad0n20:fix/ENG-11334
Open

fix(ENG-11334): preserve cedar_roperty_iri on api filter key collision#1012
Vlad0n20 wants to merge 2 commits into
CenterForOpenScience:feature/es2-consolidationfrom
Vlad0n20:fix/ENG-11334

Conversation

@Vlad0n20

Copy link
Copy Markdown
Contributor
  • Ticket: [ENG-11334]
  • Feature flag: fix

Purpose

Summary of Changes

Screenshot(s)

Side Effects

QA Notes

it('should skip the API call for a CEDAR filter found only in extraFilters (before first fetch)', () => {
const { store, mockGetFilterOptions } = setup();
store.dispatch(new SetExtraFilters([CEDAR_FILTER]));
// Intentionally no FetchResources — state.filters is still empty

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove it

Comment on lines +296 to +301
const merged = response.filters.map((apiFilter) => {
const cedarExtra = extraFilters.find((ef) => ef.key === apiFilter.key);
return cedarExtra?.cedarPropertyIri
? { ...apiFilter, cedarPropertyIri: cedarExtra.cedarPropertyIri, options: cedarExtra.options }
: apiFilter;
});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const merged = response.filters.map((apiFilter) => {
const cedarExtra = extraFilters.find((ef) => ef.key === apiFilter.key);
return cedarExtra?.cedarPropertyIri
? { ...apiFilter, cedarPropertyIri: cedarExtra.cedarPropertyIri, options: cedarExtra.options }
: apiFilter;
});
const extraByKey = new Map(extraFilters.map((ef) => [ef.key, ef]));
const merged = response.filters.map((apiFilter) => {
const cedarExtra = extraByKey.get(apiFilter.key);
if (!cedarExtra) return apiFilter;
return {
...apiFilter,
cedarPropertyIri: cedarExtra.cedarPropertyIri,
...(cedarExtra.options !== undefined && { options: cedarExtra.options }),
};
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants