diff options
| author | Barry Warsaw | 2015-02-13 03:13:06 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2015-02-13 03:13:06 -0500 |
| commit | 6d2c66ce133cd2c119fcb462dff662621013631a (patch) | |
| tree | 8ce6043cc9e95fc9bcb5ba5dab720e8b73a8c56b /src/mailman/model/uid.py | |
| parent | 7ffb6d2d43471486997c78c3cffa787a10560ecf (diff) | |
| download | mailman-6d2c66ce133cd2c119fcb462dff662621013631a.tar.gz mailman-6d2c66ce133cd2c119fcb462dff662621013631a.tar.zst mailman-6d2c66ce133cd2c119fcb462dff662621013631a.zip | |
Diffstat (limited to 'src/mailman/model/uid.py')
| -rw-r--r-- | src/mailman/model/uid.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mailman/model/uid.py b/src/mailman/model/uid.py index c0d3e4d4d..0ff22438c 100644 --- a/src/mailman/model/uid.py +++ b/src/mailman/model/uid.py @@ -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) |
