]> git.ipfire.org Git - dnsbl.git/commitdiff
sources: Store and show when sources have been updated last
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 6 Dec 2025 21:03:19 +0000 (21:03 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 6 Dec 2025 21:03:19 +0000 (21:03 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/database.sql
src/dnsbl/lists.py
src/dnsbl/sources.py

index 824cb48217c66d50cee53ba22116a62ae375ef17..35b5ec03ccddf9e449a0a501e12add97b2fcda83 100644 (file)
@@ -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
 
index 64e135fede9e32b2a732b089564f0e52b87cace5..2c1c3dfab91ec4bccf8c43672cec5c40ee4603a4 100644 (file)
@@ -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("")
index e2b7424c8cae95f14cf3e42ff5245c210b4b40df..7433e55b7206fa36c521d3b156a567d11ceb4318 100644 (file)
@@ -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()