diff --git a/jrnl/plugins/calendar_heatmap_exporter.py b/jrnl/plugins/calendar_heatmap_exporter.py index 3eecbeb20..46bf0ec58 100644 --- a/jrnl/plugins/calendar_heatmap_exporter.py +++ b/jrnl/plugins/calendar_heatmap_exporter.py @@ -39,6 +39,7 @@ def print_calendar_heatmap(cls, journal_frequency: "NestedDict") -> str: curr_year = datetime.now().year curr_month = datetime.now().month curr_day = datetime.now().day + hit_first_entry = False with console.capture() as capture: for year, month_journaling_freq in journal_frequency.items(): year_calendar = [] @@ -47,7 +48,12 @@ def print_calendar_heatmap(cls, journal_frequency: "NestedDict") -> str: break entries_this_month = sum(month_journaling_freq[month].values()) - if entries_this_month == 0: + if not hit_first_entry and entries_this_month > 0: + hit_first_entry = True + + if entries_this_month == 0 and not hit_first_entry: + continue + elif entries_this_month == 0: entry_msg = "No entries" elif entries_this_month == 1: entry_msg = "1 entry" diff --git a/tests/bdd/features/format.feature b/tests/bdd/features/format.feature index d03b1ab2c..de523ca0a 100644 --- a/tests/bdd/features/format.feature +++ b/tests/bdd/features/format.feature @@ -565,6 +565,19 @@ Feature: Custom formats | basic_dayone.yaml | +Scenario Outline: Export calendar heatmap + Given we use the config "" + And we use the password "test" if prompted + When we run "jrnl --format calendar" + Then the output should be + 2013-06-09, 1 + 2013-06-10, 1 + + Examples: configs + | config_file | + | simple.yaml | + + Scenario Outline: display_format short and pretty do not crash if specified as config values Given we use the config "" And we use the password "test" if prompted