Skip to content

Commit

Permalink
Cleanup Historic Case Archive
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMillar-MOJ committed Oct 10, 2024
1 parent 59f2f0b commit 065b7a0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cla_backend/apps/cla_butler/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
EODDetailsCategory,
Property,
)
from historic.models import CaseArchived
from timer.models import Timer
from legalaid.utils import diversity
from cla_butler.models import DiversityDataCheck, ACTION, STATUS
Expand Down Expand Up @@ -71,6 +72,7 @@ def run(self, delete_option, *args, **kwargs):
self.cleanup_adaptation_details()
self.cleanup_sessions()
self.cleanup_access_tokens()
self.cleanup_historic_casearchive()

def _setup(self):
self.now = timezone.now()
Expand Down Expand Up @@ -230,6 +232,14 @@ def cleanup_audit(self, pks):
audit_logs = AuditLog.objects.filter(complaint__in=case_complaints)
audit_logs.delete()

def cleanup_historic_casearchive(self):
""" Removes all Archived Cases that not been modified in over 3 years.
No fields in this model have a relationship to any other model.
"""
three_years_ago = self.now - relativedelta(years=3)
archived_cases = CaseArchived.objects.filter(modifed__lte=three_years_ago)
archived_cases.delete()


class DiversityDataCheckTask(Task):
def run(self, passphrase, start, end, description, *args, **kwargs):
Expand Down

0 comments on commit 065b7a0

Please sign in to comment.