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

Fix crash from reduce of empty array #198

Merged
merged 3 commits into from
Jan 2, 2025
Merged

Conversation

Minnowo
Copy link
Contributor

@Minnowo Minnowo commented Jan 2, 2025

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 | })

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Copy link
Member

@jmattheis jmattheis left a comment

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
1 check passed
@jmattheis
Copy link
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.

None yet

2 participants