Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Soft delete assets from deleted facilities/hospitals #1996

Merged
merged 26 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b7423f4
Soft delete assets from deleted facilities/hospitals
hrit2773 Mar 20, 2024
9025140
soft delete assets on deleting facility-removed redundant migrations
hrit2773 Mar 21, 2024
e95842f
added custom migrations and test cases
hrit2773 Mar 24, 2024
ebfed1b
Merge branch 'develop' into develop
hrit2773 Mar 24, 2024
ad66e21
Updated soft delete problem
hrit2773 Mar 24, 2024
1cfed7f
fix back
hrit2773 Mar 24, 2024
24f3eec
fix
hrit2773 Mar 24, 2024
cc8b5c5
Discard changes to Makefile
sainak Mar 25, 2024
e9afef8
Discard changes to config/celery_app.py
sainak Mar 25, 2024
b6f4a99
Merge branch 'develop' into develop
hrit2773 Mar 25, 2024
ea7786e
Merge branch 'coronasafe:develop' into develop
hrit2773 Mar 25, 2024
7330609
added cron job to soft delete
hrit2773 Mar 25, 2024
5f01058
changed soft delete assets
hrit2773 Mar 27, 2024
288422b
Merge branch 'coronasafe:develop' into develop
hrit2773 Mar 30, 2024
19415d0
Changed
hrit2773 Mar 30, 2024
9da57c5
Merge branch 'coronasafe:develop' into develop
hrit2773 Apr 4, 2024
5a11110
Discard changes to config/celery_app.py
sainak Apr 8, 2024
9473388
Merge branch 'develop' into develop
hrit2773 Apr 8, 2024
02e7382
Merge branch 'develop' into develop
hrit2773 Apr 15, 2024
691f9e8
Merge branch 'develop' into develop
hrit2773 Apr 24, 2024
8ea95a8
Merge branch 'develop' into develop
sainak Aug 23, 2024
1ab2e5a
fix query
sainak Aug 23, 2024
0ec7e14
Merge remote-tracking branch 'origin/develop' into hrit2773/develop
sainak Sep 22, 2024
9f31133
revert to soft deleting objects in delete method
sainak Sep 22, 2024
9a11922
wrap delete in transaction
sainak Sep 23, 2024
5850871
Merge branch 'develop' into develop
vigneshhari Sep 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions care/facility/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from care.facility.tasks.location_monitor import check_location_status
from care.facility.tasks.plausible_stats import capture_goals
from care.facility.tasks.redis_index import load_redis_index
from care.facility.tasks.soft_delete_assets import soft_delete_assets_schedule
from care.facility.tasks.summarisation import (
summarise_district_patient,
summarise_facility_capacity,
Expand Down Expand Up @@ -74,3 +75,8 @@ def setup_periodic_tasks(sender, **kwargs):
check_location_status.s(),
name="check_location_status",
)
sender.add_periodic_task(
crontab(hour="23", minute="59"),
soft_delete_assets_schedule.s(),
name="soft_delete_assets",
)
15 changes: 15 additions & 0 deletions care/facility/tasks/soft_delete_assets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from celery import shared_task

from care.facility.models.asset import Asset, AssetLocation
from care.facility.models.facility import Facility


@shared_task
def soft_delete_assets_schedule():
Asset.objects.filter(

Check warning on line 9 in care/facility/tasks/soft_delete_assets.py

View check run for this annotation

Codecov / codecov/patch

care/facility/tasks/soft_delete_assets.py#L9

Added line #L9 was not covered by tests
current_location__id__in=AssetLocation._base_manager.filter(
facility__id__in=Facility._base_manager.filter(deleted=True).values_list(
"id", flat=True
)
).values_list("id", flat=True)
).update(deleted=True)