fixed - duplicates of metas in notification call#475
Conversation
| }); | ||
|
|
||
| return result; | ||
| }; |
There was a problem hiding this comment.
This should probably be extracted to a utility. Here's my thought:
// identity.js
const identity = value => value;
// dedupe.js
const dedupe = (items, keyResolver = identity) => {
const set = new Set();
return items.filter(item => {
const key = keyResolver(item);
if (set.has(key)) {
return false;
}
set.add(key);
return true;
});
};
Example usage:
const dedupedMetas = dedupe(metas, meta => meta.id);
|
|
||
| const collectMetas = (collect, decisionMetas) => { | ||
| const metas = flatMap(decisionMetas, identity); | ||
| const dedupedMetas = dedupe(metas.map(e => e.meta)); |
There was a problem hiding this comment.
I'm a little confused by the metas naming, because I would expect each item in metas to be a meta, but it seems like it's an object with a meta property. This might be something to improve is something comes to mind for you.
|
@Aaronius could you please take a look again, I have made some other changes. We need to skip some results that contain errors from metas. We will discuss this later if we should send this data to konductor. |
| const processMetas = (collect, logger, actionResults) => { | ||
| const results = flatMap(actionResults, identity); | ||
| const finalMetas = []; | ||
| const set = new Set(); |
There was a problem hiding this comment.
Will this cause issues in IE11?
There was a problem hiding this comment.
jfkhoury
left a comment
There was a problem hiding this comment.
Looks good, other than the Set comment I added. 👍
Description
If we have a decision with multiple items we should have only one insert in the
personalization.decisionsarrayRelated Issue
Motivation and Context
Screenshots (if appropriate):
Types of changes
Checklist: