summaryrefslogtreecommitdiff
path: root/src/mailman/model/uid.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/model/uid.py')
-rw-r--r--src/mailman/model/uid.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/mailman/model/uid.py b/src/mailman/model/uid.py
index 5fcb20d53..0ff22438c 100644
--- a/src/mailman/model/uid.py
+++ b/src/mailman/model/uid.py
@@ -59,7 +59,7 @@ class UID(Model):
@staticmethod
@dbconnection
- # Note that the parameter order is deliberate reversed here. Normally,
+ # Note that the parameter order is deliberately reversed here. Normally,
# `store` is the first parameter after `self`, but since this is a
# staticmethod and there is no self, the decorator will see the uid in
# arg[0].
@@ -74,3 +74,20 @@ class UID(Model):
if existing.count() != 0:
raise ValueError(uid)
return UID(uid)
+
+ @staticmethod
+ @dbconnection
+ def get_total_uid_count(store):
+ return store.query(UID).count()
+
+ @staticmethod
+ @dbconnection
+ def cull_orphans(store):
+ # Avoid circular imports.
+ from mailman.model.user import User
+ # Delete all uids in this table that are not associated with user
+ # rows.
+ results = store.query(UID).filter(
+ ~UID.uid.in_(store.query(User._user_id)))
+ for uid in results.all():
+ store.delete(uid)