Skip to content

Commit

Permalink
StatisticsDialog: exclude empty histories
Browse files Browse the repository at this point in the history
If a YearHistory contains zero recorded dates, then StatisticsDialog
throws a NoSuchElementException from a call to java.util.SortedSet#first.

Exclude all histories, which have zero days from the statistics
gathering to fix this exception.
  • Loading branch information
rybak committed Aug 18, 2023
1 parent a051a9b commit 8f4d255
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Features
Bugfixes
- Hiding last visible habit from "Reorder habits" dialog caused an exception to
be thrown, which has been corrected.
- Gathering of statistics for habits with zero recorded dates used to throw
an exception, which has been corrected.
Improvements
- Version of Resoday shown in the "About" dialog no longer starts with a "v".

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ private static JTable createStatsTable(Histories histories) {
);
histories.forEachHistory(h -> {
NavigableSet<LocalDate> ns = h.toNavigableSet();
if (ns.isEmpty()) {
return;
}
tableModel.addRow(new Object[]{
h.getName(),
ns.size(),
Expand Down

0 comments on commit 8f4d255

Please sign in to comment.