Skip to content

Commit

Permalink
feat(SFINT-3521): reversed order of added data
Browse files Browse the repository at this point in the history
  • Loading branch information
nlafrance-coveo committed Nov 17, 2020
1 parent b95c7ea commit 4f9b151
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/components/AugmentedResultList/AugmentedResultList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,18 @@ export class AugmentedResultList extends Coveo.ResultList implements IComponentB
queryResults.results.forEach((res: Coveo.IQueryResult) => {
const match: any = remoteResults.data.resultData.find((data: any) => this.options.matchingFunction(data, res));

// Attach data specific to each result/object
// Add data common to all results
for (const key in remoteResults.data.commonData) {
res.raw[key.toLowerCase()] = (remoteResults.data.commonData as any)[key];
}

// Add data specific to each result/object
for (const key in match) {
if (key.toLowerCase() !== fieldName && Boolean(res.raw[key.toLowerCase()])) {
this.logger.warn(`The ${key} field was overwritten on result: ${res.title}`);
this.logger.trace(`The ${key} field was overwritten on result: ${res.title}`);
}
res.raw[key.toLowerCase()] = match[key];
}

// Attach data common to all results
for (const key in remoteResults.data.commonData) {
res.raw[key.toLowerCase()] = (remoteResults.data.commonData as any)[key];
}
});
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ describe('AugmentedResultList', () => {
const numResults = 10;
const data = createFakeResultsThatMatch(numResults);
const test = createComponent(stubFetchAugmentData);
const loggerSpy = sandbox.spy(Logger.prototype, 'warn');
const loggerSpy = sandbox.spy(Logger.prototype, 'trace');

// Set attribute to be overwritten.
const overwrittenResult = data.results.find((res) => res.raw.id === '#001');
Expand Down

0 comments on commit 4f9b151

Please sign in to comment.