def __str__(self):
return self.name
+ def __len__(self):
+ stmt = (
+ sqlmodel
+ .select(
+ sqlmodel.func.count(
+ sqlmodel.func.distinct(
+ sources.SourceDomain.name,
+ ),
+ ),
+ )
+ .select_from(
+ sources.Source,
+ )
+ .join(
+ sources.SourceDomain,
+ sources.SourceDomain.source_id == sources.Source.id,
+ )
+ .where(
+ sources.Source.list_id == self.id,
+ sources.Source.deleted_at == None,
+ sources.SourceDomain.removed_at == None,
+ )
+ )
+
+ return self.backend.db.fetch_one(stmt)
+
def __hash__(self):
# Only hashable once the object has an ID
if self.id is None:
def __str__(self):
return self.name
+ def __len__(self):
+ stmt = (
+ sqlmodel
+ .select(
+ sqlmodel.func.count(),
+ )
+ .select_from(
+ SourceDomain,
+ )
+ .where(
+ SourceDomain.source == self,
+ SourceDomain.removed_at == None,
+ )
+ )
+
+ return self.backend.db.fetch_one(stmt)
+
# ID
id : int = sqlmodel.Field(primary_key=True)
table.add_column(_("License"))
table.add_column(_("Created At"))
table.add_column(_("Created By"))
+ table.add_column(_("Listed Unique Domains"))
# Show all lists
for list in backend.lists:
list.license,
list.created_at.isoformat(),
list.created_by,
+ "%s" % len(list),
)
# Print the table
table.add_row(_("License"), list.license)
table.add_row(_("Created At"), list.created_at.isoformat())
table.add_row(_("Created By"), list.created_by)
+ table.add_row(_("Listed Unique Domains"), "%s" % len(list))
# Print list properties
self.console.print(table)
table.add_column(_("URL"))
table.add_column(_("Created At"))
table.add_column(_("Created_By"))
+ table.add_column(_("Listed Domains"))
for source in list.sources:
table.add_row(
source.url,
source.created_at.isoformat(),
source.created_by,
+ "%s" % len(source),
)
# Print the sources