-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: purge_personal_api_key_events() task (#7485)
* feat: purge_personal_api_key_events() task * feat: log number of events purged * test: test new task * fix: name task properly * chore: create daily PeriodicTask * chore: remove old management command * chore: remove tests of old command * test: finish removing now-empty tests.py
- Loading branch information
1 parent
607a5c8
commit 020bdeb
Showing
6 changed files
with
48 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 0 additions & 64 deletions
64
ietf/person/management/commands/purge_old_personal_api_key_events.py
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright The IETF Trust 2024, All Rights Reserved | ||
# | ||
# Celery task definitions | ||
# | ||
import datetime | ||
|
||
from celery import shared_task | ||
from django.utils import timezone | ||
|
||
from ietf.utils import log | ||
from .models import PersonApiKeyEvent | ||
|
||
|
||
@shared_task | ||
def purge_personal_api_key_events_task(keep_days): | ||
keep_since = timezone.now() - datetime.timedelta(days=keep_days) | ||
old_events = PersonApiKeyEvent.objects.filter(time__lt=keep_since) | ||
count = len(old_events) | ||
old_events.delete() | ||
log.log(f"Deleted {count} PersonApiKeyEvents older than {keep_since}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters