Skip to content

Commit

Permalink
refactor: rename cleanup to cleanup_map_frames
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasschaub committed Jun 13, 2024
1 parent 48ea54a commit f5a44ad
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion sketch_map_tool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
# Cleanup map frames and uploaded files stored in the database
"beat_schedule": {
"cleanup": {
"task": "sketch_map_tool.tasks.cleanup",
"task": "sketch_map_tool.tasks.cleanup_map_frames",
"schedule": timedelta(hours=1),
},
},
Expand Down
15 changes: 7 additions & 8 deletions sketch_map_tool/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,17 @@ def digitize_sketches(


@celery.task
def cleanup():
"""Cleanup map frames and uploaded files stored in the database."""
def cleanup_map_frames():
"""Cleanup map frames stored in the database."""
db_client_celery.cleanup_map_frames()
# TODO: run vacuum
# TODO: run Vacuum or Vacuum full?


@celery.task
def cleanup_blobs(*args, **kwargs):
def cleanup_blobs(*_):
"""Cleanup uploaded files stored in the database.
Arguments and keyword arguments are ignored.
They are only part of the signature because of usage of celery chain.
Arguments are ignored. They are only part of the signature because of usage of
celery chain.
"""
# db_client_celery.cleanup_blobs()
return ""
db_client_celery.cleanup_blobs()
13 changes: 10 additions & 3 deletions tests/integration/test_celery_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ def test_generate_quality_report(bbox_wgs84):


@pytest.mark.usefixtures("uuid_create", "uuid_digitize")
def test_cleanup():
"""Map frame is uploaded recently and uploaded sketch map has consent."""
task = tasks.cleanup.apply_async()
def test_cleanup_map_frames():
# `cleanup_map_frames()` is tested in `test_database_client_celery.py`
task = tasks.cleanup_map_frames.apply_async()
task.wait()


@pytest.mark.usefixtures("uuid_create", "uuid_digitize")
def test_cleanup_blobs():
# `cleanup_blobs()` is tested in `test_database_client_celery.py`
task = tasks.cleanup_blobs.apply_async()
task.wait()

0 comments on commit f5a44ad

Please sign in to comment.