Skip to content

Commit

Permalink
fix(core/search): Exclude duplicate results in search views (#8821)
Browse files Browse the repository at this point in the history
Signed-off-by: vjda <victorjadiaz@outlook.com>

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
vjda and mergify[bot] committed Jan 18, 2021
1 parent 4b8b469 commit 3ca7365
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { isEmpty } from 'lodash';
import { Observable, Subject } from 'rxjs';

import { UrlBuilder, IQueryParams } from 'core/navigation';
import { uniqBy } from 'lodash';

import { ISearchResultSet } from './infrastructureSearch.service';
import { ISearchResult, ISearchResults } from '../search.service';
Expand Down Expand Up @@ -33,8 +34,11 @@ export class InfrastructureSearchServiceV2 {
};

const makeResultSet = (searchResults: ISearchResults<any>, type: SearchResultType): ISearchResultSet => {
// Add URLs to each search result
const results = searchResults.results.map((result) => addComputedAttributes(result, type));
// Add URLs to each search result (discard duplicate results)
const results = uniqBy(
searchResults.results.map((result) => addComputedAttributes(result, type)),
(r) => r.href,
);
const query: string = apiParams.key as string;
return { type, results, status: SearchStatus.FINISHED, query };
};
Expand Down

0 comments on commit 3ca7365

Please sign in to comment.