Skip to content

Commit

Permalink
Standardize removal management command names
Browse files Browse the repository at this point in the history
  • Loading branch information
noliveleger committed Oct 2, 2019
1 parent bee093b commit e60400e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions kobo/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
16 changes: 8 additions & 8 deletions kpi/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

0 comments on commit e60400e

Please sign in to comment.