fix(api,dashboard): use correct id with formula

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-09-30 22:28:06 +02:00
parent 8fdc3e4033
commit da9df80079
2 changed files with 65 additions and 9 deletions

View File

@@ -99,19 +99,20 @@ export function withFormula(
};
});
}
return [
{
...series[0],
data: series[0].data.map((item, dIndex) => {
const scope = series.reduce((acc, item) => {
if (!item.event.id) {
return acc;
const scope = series.reduce((acc, item, index) => {
const readableId = alphabetIds[index];
if (!readableId) {
throw new Error('no alphabet id for serie in withFormula');
}
return {
...acc,
[item.event.id]: item.data[dIndex]?.count ?? 0,
[readableId]: item.data[dIndex]?.count ?? 0,
};
}, {});