def _as_vgrouprows(visits) -> tg.List[tg.Optional[VGroupRow]]: vgrouprows: tg.List[tg.Optional[VGroupRow]] = [] v: arm.Visit for idx, v in enumerate(visits): if v is None: row = None else: distance = getattr(v, 'distance', None) distance = "%5.1fm" % v.distance if distance is not None else "?" row = VGroupRow( v.familyname, v.givenname, v.email, v.phone, v.street_and_number, v.zipcode, v.town, v.status_3g_txt, v.cookie, distance, # type: ignore aud.dtstring(v.submission_dt, time=True), aud.dtstring(v.present_from_dt, date=False, time=True), aud.dtstring(v.present_to_dt, date=False, time=True), v.seat.room.organization, v.seat.room.department, v.seat.room.building, v.seat.room.room, v.seat.seatname) vgrouprows.append(row) return vgrouprows
def handle(self, *args, **options): horizon = djut.localtime() - dt.timedelta( days=settings.DATA_RETENTION_DAYS) oldvisits = arm.Visit.objects.filter(submission_dt__lt=horizon) howmany_deleted = oldvisits.count() howmany_exist = arm.Visit.objects.count() msg = "delete_outdated_data: deleting %d visit entries before %s (of %d existing)" % \ (howmany_deleted, aud.dtstring(horizon), howmany_exist) logging.info(msg) oldvisits.delete()
def handle(self, *args, **options): #--- deleted data older than retention time: horizon = djut.localtime() - dt.timedelta( days=settings.DATA_RETENTION_DAYS) oldvisits = arm.Visit.objects.filter(submission_dt__lt=horizon) howmany_deleted = oldvisits.count() howmany_exist = arm.Visit.objects.count() msg = "delete_outdated_data: deleting %d visit entries before %s (of %d existing)" % \ (howmany_deleted, aud.dtstring(horizon), howmany_exist) logging.info(msg) oldvisits.delete() #--- deleted status_3g field in data older than status_3g retention time: if not settings.USE_STATUS_3G_FIELD or \ settings.DATA_RETENTION_DAYS_STATUS_3G >= settings.DATA_RETENTION_DAYS: return # nothing else to do horizon_3g = djut.localtime() - dt.timedelta( days=settings.DATA_RETENTION_DAYS_STATUS_3G) youngvisits = arm.Visit.objects.filter(submission_dt__lt=horizon_3g) howmany_cleaned = youngvisits.count() howmany_exist = arm.Visit.objects.count() msg = "delete_outdated_data: cleansing %d status_3g values before %s (of %d existing)" % \ (howmany_cleaned, aud.dtstring(horizon_3g, time=True), howmany_exist) logging.info(msg) youngvisits.update(status_3g=arm.G_UNKNOWN)