diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2011-03-29 16:36:20 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2011-03-29 16:36:20 +0200 |
commit | 5dee876e9956203f24da46a52021a16b211d6058 (patch) | |
tree | 2a1983a5c8b9e4b126e42cea9f119a18f300d8b5 | |
parent | 722cbca65f37a7e265a9e45d320e8319cd51bfa8 (diff) |
tracking: Remove stale empty consignments.
-rw-r--r-- | modules/tracking.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/tracking.py b/modules/tracking.py index 43435a1..031748b 100644 --- a/modules/tracking.py +++ b/modules/tracking.py @@ -346,6 +346,11 @@ class Module: self.irc.msg(target, msg.encode('utf-8')) session.delete(package) removed = True + # empty consignment and 30 days old + if len(consignment.packages) == 0 and consignment.added < datetime.datetime.utcnow() - datetime.timedelta(hours = 24*30): + msg = '%s: Removing stale consignment \002%s\002%s' % (consignment.nick, consignment.code, label) + self.irc.msg(target, msg.encode('utf-8')) + session.delete(consignment) if removed and len(consignment.packages) == 0: msg = '%s: \002%s\002%s is no longer being tracked' % (consignment.nick, consignment.code, label) self.irc.msg(target, msg.encode('utf-8')) |