]> git.ipfire.org Git - dbl.git/commitdiff
lists: Fetch sources ordered by their name
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 6 Dec 2025 19:29:33 +0000 (19:29 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 6 Dec 2025 19:29:33 +0000 (19:29 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/dnsbl/lists.py

index 679cdaa17a64eec2cd1db8c5a597b87956eff162..887053dcd31fb962de836306a9e78c2b62e5bad9 100644 (file)
@@ -133,7 +133,16 @@ class List(sqlmodel.SQLModel, database.BackendMixin, table=True):
        license : str
 
        # Sources
-       sources : typing.List["Source"] = sqlmodel.Relationship(back_populates="list")
+       sources : typing.List["Source"] = sqlmodel.Relationship(
+               back_populates="list",
+               sa_relationship_kwargs={
+                       "primaryjoin" : """and_(
+                               Source.list_id == List.id,
+                               Source.deleted_at == None,
+                       )""",
+                       "order_by"    : "Source.name",
+                },
+       )
 
        # Updated At
        updated_at : datetime.datetime | None