From: Michael Tremer Date: Sat, 6 Dec 2025 21:03:19 +0000 (+0000) Subject: sources: Store and show when sources have been updated last X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27dc2683984629a92f577780fc50ad88bfd8e788;p=dnsbl.git sources: Store and show when sources have been updated last Signed-off-by: Michael Tremer --- diff --git a/src/database.sql b/src/database.sql index 824cb48..35b5ec0 100644 --- a/src/database.sql +++ b/src/database.sql @@ -2,7 +2,7 @@ -- PostgreSQL database dump -- -\restrict TaZrdGusaZTZc5ekYVHEJsrYrMffEbVutlJGqxNWtDAodc7zBA9kzI4e9yJcOiz +\restrict EcVPjzzaAxJjnzRDIpbc5yv5dhcWfScauYVZ8LFOgEDGgDejiH1MIE95SYJrtnU -- Dumped from database version 17.6 (Debian 17.6-0+deb13u1) -- Dumped by pg_dump version 17.6 (Debian 17.6-0+deb13u1) @@ -164,7 +164,8 @@ CREATE TABLE public.sources ( license text NOT NULL, list_id integer, last_modified_at timestamp with time zone, - etag text + etag text, + updated_at timestamp with time zone ); @@ -372,5 +373,5 @@ ALTER TABLE ONLY public.sources -- PostgreSQL database dump complete -- -\unrestrict TaZrdGusaZTZc5ekYVHEJsrYrMffEbVutlJGqxNWtDAodc7zBA9kzI4e9yJcOiz +\unrestrict EcVPjzzaAxJjnzRDIpbc5yv5dhcWfScauYVZ8LFOgEDGgDejiH1MIE95SYJrtnU diff --git a/src/dnsbl/lists.py b/src/dnsbl/lists.py index 64e135f..2c1c3df 100644 --- a/src/dnsbl/lists.py +++ b/src/dnsbl/lists.py @@ -325,6 +325,8 @@ class List(sqlmodel.SQLModel, database.BackendMixin, table=True): for source in self.sources: lines.append(" * %s (%s)" % (source.name, source.license)) lines.append(" %s" % source.url) + if source.updated_at: + lines.append(" Updated: %s" % source.updated_at.isoformat()) # Newline lines.append("") diff --git a/src/dnsbl/sources.py b/src/dnsbl/sources.py index e2b7424..7433e55 100644 --- a/src/dnsbl/sources.py +++ b/src/dnsbl/sources.py @@ -112,6 +112,9 @@ class Source(sqlmodel.SQLModel, database.BackendMixin, table=True): # ETag etag : str | None + # Updated At + updated_at : datetime.datetime | None + # Domains domains : "SourceDomain" = sqlmodel.Relationship(back_populates="source") @@ -178,6 +181,9 @@ class Source(sqlmodel.SQLModel, database.BackendMixin, table=True): except ValueError as e: log.warning("Failed to add '%s' to the database: %s" % (domain, e)) + # The list has now been updated + self.updated_at = sqlmodel.func.current_timestamp() + # Mark all domains that have not been updated as removed self.__prune()