ФУНКЦИИ - МЕЖПРОЕКТНАЯ КОММУНИКАЦИЯ: retention cleanup файлового хранилища

This commit is contained in:
DCCONSTRUCTIONS
2026-04-27 13:47:46 +03:00
parent 3e328531ec
commit a7606f2e9a
3 changed files with 81 additions and 2 deletions
@@ -112,6 +112,7 @@ def restore_related_objects(app_label, model_name, instance_pk, using=None):
@shared_task
def hard_delete():
from plane.bgtasks.file_asset_task import delete_expired_file_asset
from plane.db.models import (
Workspace,
Project,
@@ -134,6 +135,9 @@ def hard_delete():
)
days = settings.HARD_DELETE_AFTER_DAYS
delete_expired_file_asset()
# check delete workspace
_ = Workspace.all_objects.filter(deleted_at__lt=timezone.now() - timezone.timedelta(days=days)).delete()
@@ -185,6 +189,9 @@ def hard_delete():
# Iterate through all models
for model in all_models:
if model._meta.label_lower in {"db.fileasset", "db.storedblob"}:
continue
# Check if the model has a 'deleted_at' field
if hasattr(model, "deleted_at"):
# Get all instances where 'deleted_at' is greater than 30 days ago