-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e945aa9
commit 3b3f94e
Showing
6 changed files
with
72 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Python imports | ||
from datetime import timedelta | ||
|
||
# Django imports | ||
from django.utils import timezone | ||
from django.db.models import Q | ||
|
||
# Third party imports | ||
from celery import shared_task | ||
|
||
# Module imports | ||
from plane.db.models import FileAsset | ||
|
||
|
||
@shared_task | ||
def delete_file_asset(): | ||
|
||
# file assets to delete | ||
file_assets_to_delete = FileAsset.objects.filter( | ||
Q(is_deleted=True) & Q(updated_at__lte=timezone.now() - timedelta(days=7)) | ||
) | ||
|
||
# Delete the file from storage and the file object from the database | ||
for file_asset in file_assets_to_delete: | ||
# Delete the file from storage | ||
file_asset.asset.delete(save=False) | ||
# Delete the file object | ||
file_asset.delete() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
apiserver/plane/db/migrations/0051_fileasset_is_deleted.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 4.2.7 on 2023-11-20 08:26 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('db', '0050_user_use_case_alter_workspace_organization_size'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='fileasset', | ||
name='is_deleted', | ||
field=models.BooleanField(default=False), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters