mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
More refactoring
This commit is contained in:
parent
7a32e7a8c1
commit
491739019c
3 changed files with 6 additions and 6 deletions
|
@ -13,7 +13,7 @@ from rich.table import Table
|
|||
from rich.text import Text
|
||||
|
||||
from jrnl.plugins.text_exporter import TextExporter
|
||||
from jrnl.plugins.util import get_journal_frequency_as_dict
|
||||
from jrnl.plugins.util import get_journal_frequency_nested
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from jrnl.datatypes import NestedDict
|
||||
|
@ -107,5 +107,5 @@ class CalendarHeatmapExporter(TextExporter):
|
|||
@classmethod
|
||||
def export_journal(cls, journal: "Journal"):
|
||||
"""Returns dates and their frequencies for an entire journal."""
|
||||
journal_entry_date_frequency = get_journal_frequency_as_dict(journal)
|
||||
journal_entry_date_frequency = get_journal_frequency_nested(journal)
|
||||
return cls.print_calendar_heatmap(journal_entry_date_frequency)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
from jrnl.plugins.text_exporter import TextExporter
|
||||
from jrnl.plugins.util import get_journal_frequency_as_str
|
||||
from jrnl.plugins.util import get_journal_frequency_one_level
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from jrnl.journals import Entry
|
||||
|
@ -24,6 +24,6 @@ class DatesExporter(TextExporter):
|
|||
@classmethod
|
||||
def export_journal(cls, journal: "Journal") -> str:
|
||||
"""Returns dates and their frequencies for an entire journal."""
|
||||
date_counts = get_journal_frequency_as_str(journal)
|
||||
date_counts = get_journal_frequency_one_level(journal)
|
||||
result = "\n".join(f"{date}, {count}" for date, count in date_counts.items())
|
||||
return result
|
||||
|
|
|
@ -33,7 +33,7 @@ def oxford_list(lst: list) -> str:
|
|||
return ", ".join(lst[:-1]) + ", or " + lst[-1]
|
||||
|
||||
|
||||
def get_journal_frequency_as_dict(journal: "Journal") -> NestedDict:
|
||||
def get_journal_frequency_nested(journal: "Journal") -> NestedDict:
|
||||
"""Returns a NestedDict of the form {year: {month: {day: count}}}"""
|
||||
journal_frequency = NestedDict()
|
||||
for entry in journal.entries:
|
||||
|
@ -46,7 +46,7 @@ def get_journal_frequency_as_dict(journal: "Journal") -> NestedDict:
|
|||
return journal_frequency
|
||||
|
||||
|
||||
def get_journal_frequency_as_str(journal: "Journal") -> Counter:
|
||||
def get_journal_frequency_one_level(journal: "Journal") -> Counter:
|
||||
"""Returns a Counter of the form {date (YYYY-MM-DD): count}"""
|
||||
date_counts = Counter()
|
||||
for entry in journal.entries:
|
||||
|
|
Loading…
Add table
Reference in a new issue