Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AA - Prioritize valid data in timeline #1338

Merged
merged 13 commits into from
Sep 25, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,24 @@ export function timelineTransform({
filtered.forEach(x => {
const key = getColumnKey(x);
const val = categoriesMap.get(key);
categoriesMap.set(
key,
val
? { status: val.status, data: [...val.data, x] }
: {
status: {
category: x.category,
phase: x.phase,
},
data: [x],
},
);
if (val) {
// Prioritize valid elements when multiple indicators overlap on the same date
const existingValidItem = val.data.find(
item => item.isValid && item.date === x.date,
);
if (!existingValidItem || x.isValid) {
// eslint-disable-next-line fp/no-mutation
val.data = [...val.data.filter(item => item.date !== x.date), x];
}
} else {
categoriesMap.set(key, {
status: {
category: x.category,
phase: x.phase,
},
data: [x],
});
}
});
return [win, { months, rows: Object.fromEntries(categoriesMap) }];
}) as [
Expand Down
Loading