def run(self, args, logger): log_region('ALL') data_deleter = DataDeleter(dry_run=args.dry_run) data_deleter.delete_rankings() data_deleter.delete_cache_data() return 0
def run(self, args, logger): keep_ids = (int(id) for id in args.keep_rankings.split(",")) with transaction.atomic(): remove_ids = [ r.id for r in Ranking.objects.exclude(id__in=keep_ids) ] data_deleter = DataDeleter(dry_run=not args.delete) data_archiver = DataArchiver(utcnow(), remove=True) # Remove rankings. for remove_id in remove_ids: data_deleter.delete_ranking(remove_id) # Archive all rankings except the last. if args.delete: rankings = Ranking.objects.order_by("-id")[1:] for ranking in rankings: logger.info(f"archiving ranking {ranking.id}") data_archiver.archive_ranking(ranking, self.check_stop) else: logger.info("DRY RUN no archiving of rankings") # Delete ladders that are no longer needed. keep_season_ids = {r.season_id for r in Ranking.objects.all()} data_deleter.delete_ladders(tuple(keep_season_ids)) # Delete cache data that is unused. data_deleter.agressive_delete_cache_data() # Purge players and teams. if args.delete: purge_player_data(check_stop=self.check_stop) else: logger.info("DRY RUN no purge player data") return 0
def delete(keep_last=None, dry_run=None): dd = DataDeleter(dry_run=dry_run) dd.delete_rankings(keep_last=keep_last) dd.delete_cache_data()
def run(self, args, logger): data_deleter = DataDeleter(dry_run=not args.delete) data_deleter.delete_ranking(args.ranking) return 0