mirror of
https://github.com/umap-project/umap.git
synced 2025-04-28 19:42:36 +02:00
chore: review empty_trash command (#2360)
- do not try to print map.id after delete (it's None) - rely on date instead of minutes/microseconds
This commit is contained in:
commit
a574db73e5
1 changed files with 5 additions and 2 deletions
|
@ -23,10 +23,13 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
days = options["days"]
|
days = options["days"]
|
||||||
since = datetime.utcnow() - timedelta(days=days)
|
since = (datetime.utcnow() - timedelta(days=days)).date()
|
||||||
print(f"Deleting map in trash since {since}")
|
print(f"Deleting map in trash since {since}")
|
||||||
maps = Map.objects.filter(share_status=Map.DELETED, modified_at__lt=since)
|
maps = Map.objects.filter(share_status=Map.DELETED, modified_at__lt=since)
|
||||||
for map in maps:
|
for map in maps:
|
||||||
|
map_id = map.id
|
||||||
|
map_name = map.name
|
||||||
|
trashed_at = map.modified_at.date()
|
||||||
if not options["dry_run"]:
|
if not options["dry_run"]:
|
||||||
map.delete()
|
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}")
|
||||||
|
|
Loading…
Reference in a new issue