From 39044458f19a55d569abc9f79a70edbf138f696b Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 25 Oct 2022 12:28:47 -0400 Subject: [PATCH] feat: `since: forever` will include all activity regardless of time. #22 --- README.rst | 4 +++- scriv.d/20221025_122731_nedbat.rst | 5 +++++ src/dinghy/digest.py | 9 +++++++-- src/dinghy/templates/digest.html.j2 | 10 ++++++++-- 4 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 scriv.d/20221025_122731_nedbat.rst diff --git a/README.rst b/README.rst index 6588bd1..6c30f9d 100644 --- a/README.rst +++ b/README.rst @@ -90,7 +90,9 @@ clause sets defaults for the digest options in the rest of the file. Each - The ``since`` setting indicates how far back to look for activity. It can use units of weeks, days, hours, minutes and seconds, and can also be - abbreviated, like ``1d6h``. If omitted, it defaults to one week. + abbreviated, like ``1d6h``. Using ``since: forever`` will include all + activity regardless of when it happened. If ``since`` is omitted, it + defaults to one week. - The ``items`` setting is a list of things to report on, specified in a few different ways: diff --git a/scriv.d/20221025_122731_nedbat.rst b/scriv.d/20221025_122731_nedbat.rst new file mode 100644 index 0000000..ea057a8 --- /dev/null +++ b/scriv.d/20221025_122731_nedbat.rst @@ -0,0 +1,5 @@ +Added +..... + +- You can now specify ``since: forever`` to include all activity regardless of + when it happened. diff --git a/src/dinghy/digest.py b/src/dinghy/digest.py index 5ad82af..c6138e4 100644 --- a/src/dinghy/digest.py +++ b/src/dinghy/digest.py @@ -462,7 +462,12 @@ async def make_digest(items, since="1 week", digest="digest.html", **options): digest (str): the HTML file name to write. """ - since_date = datetime.datetime.now() - parse_timedelta(since) + if since == "forever": + show_date = False + since_date = datetime.datetime(year=1980, month=1, day=1) + else: + show_date = True + since_date = datetime.datetime.now() - parse_timedelta(since) digester = Digester(since=since_date, options=options) coros = [] @@ -487,7 +492,7 @@ async def make_digest(items, since="1 week", digest="digest.html", **options): "digest.html.j2", digest, results=results, - since=since_date, + since=since_date if show_date else None, now=datetime.datetime.now(), __version__=__version__, title=options.get("title", ""), diff --git a/src/dinghy/templates/digest.html.j2 b/src/dinghy/templates/digest.html.j2 index 6f4ade9..6e7c593 100644 --- a/src/dinghy/templates/digest.html.j2 +++ b/src/dinghy/templates/digest.html.j2 @@ -1,6 +1,12 @@ {# The template for the digest.html output file. -#} +{%- macro page_title() -%} + {{ title }} + {% if title and since %} — {% endif %} + {% if since %}Activity since {{ since|datetime("%Y-%m-%d") }}{% endif %} +{%- endmacro -%} + {%- macro octicon_url(name, size=16) -%} {#- Octicons: https://github.com/primer/octicons/tree/main/icons -#} {#- also: https://primer.style/octicons/ -#} @@ -28,7 +34,7 @@ - {% if title %}{{ title }} — {% endif %}Activity since {{ since|datetime("%Y-%m-%d") }} + {{ page_title() }} -

{% if title %}{{ title }} - {% endif %}Activity since {{ since|datetime("%Y-%m-%d") }}

+

{{ page_title() }}