From 5d0b7dff4c7b865167f087f5cf4c48848b9aa76c Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Thu, 12 Dec 2024 13:47:40 +0100 Subject: [PATCH] chore: review empty_trash command - do not try to print map.id after delete (it's None) - rely on date instead of minutes/microseconds --- umap/management/commands/empty_trash.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/umap/management/commands/empty_trash.py b/umap/management/commands/empty_trash.py index 3a79e7127..774dabe36 100644 --- a/umap/management/commands/empty_trash.py +++ b/umap/management/commands/empty_trash.py @@ -23,10 +23,13 @@ def add_arguments(self, parser): def handle(self, *args, **options): days = options["days"] - since = datetime.utcnow() - timedelta(days=days) + since = (datetime.utcnow() - timedelta(days=days)).date() print(f"Deleting map in trash since {since}") maps = Map.objects.filter(share_status=Map.DELETED, modified_at__lt=since) for map in maps: + map_id = map.id + map_name = map.name + trashed_at = map.modified_at.date() if not options["dry_run"]: map.delete() - print(f"Deleted map {map.name} ({map.id}), trashed on {map.modified_at}") + print(f"Deleted map {map_name} ({map_id}), trashed at {trashed_at}")