From e60400ed63f21319cf7d255a673115bab9a75ff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20L=C3=A9ger?= Date: Wed, 2 Oct 2019 12:46:57 -0400 Subject: [PATCH] Standardize removal management command names --- kobo/settings/base.py | 8 ++++---- ...et_snapshots.py => remove_asset_snapshots.py} | 6 +++--- ...te_base_command.py => remove_base_command.py} | 6 +++--- ...te_import_tasks.py => remove_import_tasks.py} | 6 +++--- kpi/tasks.py | 16 ++++++++-------- 5 files changed, 21 insertions(+), 21 deletions(-) rename kpi/management/commands/{delete_asset_snapshots.py => remove_asset_snapshots.py} (89%) rename kpi/management/commands/{delete_base_command.py => remove_base_command.py} (95%) rename kpi/management/commands/{delete_import_tasks.py => remove_import_tasks.py} (78%) diff --git a/kobo/settings/base.py b/kobo/settings/base.py index c515bb3657..7a143a6cb2 100644 --- a/kobo/settings/base.py +++ b/kobo/settings/base.py @@ -448,20 +448,20 @@ def __init__(self, *args, **kwargs): 'options': {'queue': 'kpi_queue'} }, # Schedule every Saturday at 4:00 AM UTC. Can be customized in admin section - 'clean-orphans': { - 'task': 'kpi.tasks.clean_orphans', + 'remove-s3-orphans': { + 'task': 'kpi.tasks.remove_s3_orphans', 'schedule': crontab(hour=4, minute=0, day_of_week=6), 'options': {'queue': 'kpi_queue'} }, # Schedule every Friday at 4:00 AM UTC. Can be customized in admin section 'delete-asset-snapshots': { - 'task': 'kpi.tasks.delete_asset_snapshots', + 'task': 'kpi.tasks.remove_asset_snapshots', 'schedule': crontab(hour=4, minute=0, day_of_week=5), 'options': {'queue': 'kpi_queue'} }, # Schedule every Friday at 5:00 AM UTC. Can be customized in admin section 'delete-import-tasks': { - 'task': 'kpi.tasks.delete_import_tasks', + 'task': 'kpi.tasks.remove_import_tasks', 'schedule': crontab(hour=5, minute=0, day_of_week=5), 'options': {'queue': 'kpi_queue'} }, diff --git a/kpi/management/commands/delete_asset_snapshots.py b/kpi/management/commands/remove_asset_snapshots.py similarity index 89% rename from kpi/management/commands/delete_asset_snapshots.py rename to kpi/management/commands/remove_asset_snapshots.py index e7e6599c29..96fe651dc4 100644 --- a/kpi/management/commands/delete_asset_snapshots.py +++ b/kpi/management/commands/remove_asset_snapshots.py @@ -6,13 +6,13 @@ from django.db.models import Max from django.utils import timezone -from .delete_base_command import DeleteBaseCommand +from .remove_base_command import RemoveBaseCommand from kpi.models import AssetSnapshot -class Command(DeleteBaseCommand): +class Command(RemoveBaseCommand): - help = "Deletes asset snapshots" + help = "Removes asset snapshots" def _prepare_delete_queryset(self, **options): days = options["days"] diff --git a/kpi/management/commands/delete_base_command.py b/kpi/management/commands/remove_base_command.py similarity index 95% rename from kpi/management/commands/delete_base_command.py rename to kpi/management/commands/remove_base_command.py index b541f9aac4..f272a5e74a 100644 --- a/kpi/management/commands/delete_base_command.py +++ b/kpi/management/commands/remove_base_command.py @@ -7,14 +7,14 @@ from django.db import transaction, connection -class DeleteBaseCommand(BaseCommand): +class RemoveBaseCommand(BaseCommand): def __init__(self, stdout=None, stderr=None, no_color=False): - super(DeleteBaseCommand, self).__init__(stdout=stdout, stderr=stderr, no_color=no_color) + super(RemoveBaseCommand, self).__init__(stdout=stdout, stderr=stderr, no_color=no_color) self._model = None def add_arguments(self, parser): - super(DeleteBaseCommand, self).add_arguments(parser) + super(RemoveBaseCommand, self).add_arguments(parser) parser.add_argument( "--days", default=90, diff --git a/kpi/management/commands/delete_import_tasks.py b/kpi/management/commands/remove_import_tasks.py similarity index 78% rename from kpi/management/commands/delete_import_tasks.py rename to kpi/management/commands/remove_import_tasks.py index 3fddc172b9..42fdc46c0e 100644 --- a/kpi/management/commands/delete_import_tasks.py +++ b/kpi/management/commands/remove_import_tasks.py @@ -5,13 +5,13 @@ from django.utils import timezone -from .delete_base_command import DeleteBaseCommand +from .remove_base_command import RemoveBaseCommand from kpi.models import ImportTask -class Command(DeleteBaseCommand): +class Command(RemoveBaseCommand): - help = "Deletes import tasks" + help = "Removes import tasks" def _prepare_delete_queryset(self, **options): days = options["days"] diff --git a/kpi/tasks.py b/kpi/tasks.py index 4566d21f6c..07bd1a96bf 100644 --- a/kpi/tasks.py +++ b/kpi/tasks.py @@ -38,19 +38,19 @@ def import_survey_drafts_from_dkobo(**kwargs): @shared_task -@lock(key='clean_orphans', timeout=60) -def clean_orphans(): +@lock(key='remove_s3_orphans', timeout=60) +def remove_s3_orphans(): #ToDo Create Management command pass @shared_task -@lock(key='delete_asset_snapshots', timeout=60) -def delete_asset_snapshots(): - call_command('delete_asset_snapshots') +@lock(key='remove_asset_snapshots', timeout=60) +def remove_asset_snapshots(): + call_command('remove_asset_snapshots') @shared_task -@lock(key='delete_import_tasks', timeout=60) -def delete_import_tasks(): - call_command('delete_import_tasks') +@lock(key='remove_import_tasks', timeout=60) +def remove_import_tasks(): + call_command('remove_import_tasks')