Skip to content

Fix crash from reduce of empty array#198

Merged
jmattheis merged 3 commits into
traggo:masterfrom
Minnowo:master
Jan 2, 2025
Merged

Fix crash from reduce of empty array#198
jmattheis merged 3 commits into
traggo:masterfrom
Minnowo:master

Conversation

@Minnowo

@Minnowo Minnowo commented Jan 2, 2025

Copy link
Copy Markdown
Contributor

One of my dashboard is failing because of the change of year. This fixes it. I also added a divide by 0 check in the % calculation on pie charts since I was thinking that was the problem at first.

TypeError: reduce of empty array with no initial value
./src/dashboard/Entry/DashboardTable.tsx/DashboardTable/indexedEntries<
src/dashboard/Entry/DashboardTable.tsx:34

  31 |         }, {}),
  32 |     };
  33 |     if (total) {
> 34 |         result.data['Total'] = Object.values(result.data).reduce((acc, value) => acc + value);
     | ^  35 |     }
  36 |     return result;
  37 | })

@jmattheis jmattheis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've fixed the underlying issue where the no data check wasn't correctly implemented for all dashboard chart types.

@jmattheis
jmattheis merged commit 05c5807 into traggo:master Jan 2, 2025
@jmattheis

Copy link
Copy Markdown
Member

Released with v0.6.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants