def test_utc_dynamic_date(self): a = utility.utc_dynamic_date(utility.datetime_null()) b = utility.utc_dynamic_date(utility.datetime_null(), seconds=0, minutes=0, hours=0) self.assertTrue(a == b) c = utility.utc_dynamic_date(utility.datetime_null(), seconds=121, minutes=120, hours=0) d = utility.utc_dynamic_date(utility.datetime_null(), seconds=61, minutes=61, hours=1) e = utility.utc_dynamic_date(utility.datetime_null(), seconds=1, minutes=2, hours=2) self.assertEqual(c, d) self.assertEqual(d, e) f = utility.utc_dynamic_date(c, seconds=121, minutes=120, hours=0) g = utility.utc_dynamic_date(d, seconds=61, minutes=61, hours=1) h = utility.utc_dynamic_date(e, seconds=1, minutes=2, hours=2) self.assertEqual(c, d) self.assertEqual(d, e)
def get_tip_timings(store, new): itip_list = store.find(InternalTip, InternalTip.new == new) tipinfo_list = [] for itip in itip_list: comment_cnt = store.find(Comment, Comment.internaltip_id == itip.id).count() files_cnt = store.find(InternalFile, InternalFile.internaltip_id == itip.id).count() tip_timetolive = itip.context.tip_timetolive serialized_tipinfo = { 'id': itip.id, 'creation_date': datetime_to_ISO8601(itip.creation_date), 'expiration_date': datetime_to_ISO8601(itip.expiration_date), 'upcoming_expiration_date': datetime_to_ISO8601(utc_dynamic_date(itip.expiration_date, hours=72)), 'tip_life_seconds': tip_timetolive, 'files': files_cnt, 'comments': comment_cnt, } tipinfo_list.append(serialized_tipinfo) return tipinfo_list
def get_tip_timings(store): itip_list = store.find(InternalTip) tipinfo_list = [] for itip in itip_list: comment_cnt = store.find(Comment, Comment.internaltip_id == itip.id).count() files_cnt = store.find(InternalFile, InternalFile.internaltip_id == itip.id).count() tip_timetolive = itip.context.tip_timetolive serialized_tipinfo = { 'id': itip.id, 'creation_date': datetime_to_ISO8601(itip.creation_date), 'expiration_date': datetime_to_ISO8601(itip.expiration_date), 'upcoming_expiration_date': datetime_to_ISO8601(utc_dynamic_date(itip.expiration_date, hours=-72)), 'tip_life_seconds': tip_timetolive, 'files': files_cnt, 'comments': comment_cnt, } # TODO, query ReceiverFile and ReceiverTip and check if the status is 'new' # in CleaningSched, if some of the 'new' is going to be deleted, we are # spotting a serious (sorry for the latinism) 'fancazzismo cronicarum' and the # Admin can be alerted about. tipinfo_list.append(serialized_tipinfo) return tipinfo_list