From 5dee876e9956203f24da46a52021a16b211d6058 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Tue, 29 Mar 2011 16:36:20 +0200 Subject: tracking: Remove stale empty consignments. --- modules/tracking.py | 5 +++++ 1 file changed, 5 insertions(+) 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')) -- cgit v1.2.3