Skip to content

Commit

Permalink
feat: since: forever will include all activity regardless of time. #22
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Oct 25, 2022
1 parent 730227e commit 3904445
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions scriv.d/20221025_122731_nedbat.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Added
.....

- You can now specify ``since: forever`` to include all activity regardless of
when it happened.
9 changes: 7 additions & 2 deletions src/dinghy/digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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", ""),
Expand Down
10 changes: 8 additions & 2 deletions src/dinghy/templates/digest.html.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<!DOCTYPE html>
{# 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/ -#}
Expand Down Expand Up @@ -28,7 +34,7 @@

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{% if title %}{{ title }} — {% endif %}Activity since {{ since|datetime("%Y-%m-%d") }}</title>
<title>{{ page_title() }}</title>
<link rel="icon" href="{{ octicon_url("comment-discussion", 24) }}" type="image/svg+xml">
<style>
body {
Expand Down Expand Up @@ -180,7 +186,7 @@
</style>
<body>

<h1>{% if title %}{{ title }} - {% endif %}Activity since {{ since|datetime("%Y-%m-%d") }}</h1>
<h1>{{ page_title() }}</h1>

<ul class="repos">
{% for container in results -%}
Expand Down

0 comments on commit 3904445

Please sign in to comment.