diff --git a/apiserver/plane/api/serializers/issue.py b/apiserver/plane/api/serializers/issue.py index 447a9c65e..b529beeaf 100644 --- a/apiserver/plane/api/serializers/issue.py +++ b/apiserver/plane/api/serializers/issue.py @@ -78,7 +78,7 @@ class IssueSerializer(BaseSerializer): parsed_str = html.tostring(parsed, encoding="unicode") data["description_html"] = parsed_str - except Exception as e: + except Exception: raise serializers.ValidationError("Invalid HTML passed") # Validate assignees are from project @@ -349,7 +349,7 @@ class IssueCommentSerializer(BaseSerializer): parsed_str = html.tostring(parsed, encoding="unicode") data["comment_html"] = parsed_str - except Exception as e: + except Exception: raise serializers.ValidationError("Invalid HTML passed") return data diff --git a/apiserver/plane/bgtasks/file_asset_task.py b/apiserver/plane/bgtasks/file_asset_task.py index 91c17ecc8..b2ecfddd4 100644 --- a/apiserver/plane/bgtasks/file_asset_task.py +++ b/apiserver/plane/bgtasks/file_asset_task.py @@ -1,13 +1,13 @@ # 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 +# Django imports +from django.db.models import Q +from django.utils import timezone + # Module imports from plane.db.models import FileAsset @@ -29,25 +29,8 @@ def delete_file_asset(): @shared_task -def file_asset_size(slug, email, members, issue_count, cycle_count, module_count): +def file_asset_size(): asset_size = [] - # s3_client = boto3.client('s3') - assets_to_update = [] - - # for asset in FileAsset.objects.filter(size__isnull=True): - # try: - # key = f"{workspace_id}/{asset_key}" - # response = s3_client.head_object(Bucket=settings.AWS_STORAGE_BUCKET_NAME, Key=key) - # size = response['ContentLength'] - # asset.size = size - # assets_to_update.append(asset) - # except Exception as e: - # # Handle exceptions such as S3 object not found - # print(f"Error updating asset size for {asset.asset.key}: {e}") - - # # Bulk update only objects that need updating - # FileAsset.objects.bulk_update(assets_to_update, ["size"], batch_size=50) - for asset in FileAsset.objects.filter(size__isnull=True): asset.size = asset.asset.size asset_size.append(asset) diff --git a/apiserver/plane/db/management/commands/file_asset_size.py b/apiserver/plane/db/management/commands/file_asset_size.py index 462a1b817..dc693a0a5 100644 --- a/apiserver/plane/db/management/commands/file_asset_size.py +++ b/apiserver/plane/db/management/commands/file_asset_size.py @@ -1,23 +1,21 @@ # Python imports -import getpass # Django imports from django.core.management import BaseCommand # Module imports -from plane.db.models import User class Command(BaseCommand): help = "Check the file asset size of the file" - def handle(self, *args, **options): from plane.bgtasks.file_asset_task import file_asset_size + # Start the queueing file_asset_size.delay() self.stdout.write( - self.style.SUCCESS(f"File asset size pushed to queue") + self.style.SUCCESS("File asset size pushed to queue") ) diff --git a/apiserver/plane/db/models/issue.py b/apiserver/plane/db/models/issue.py index a0695a2cb..0306e4fa0 100644 --- a/apiserver/plane/db/models/issue.py +++ b/apiserver/plane/db/models/issue.py @@ -1,5 +1,9 @@ +# Python imports +import uuid + # Django imports from django.conf import settings +from django.core.exceptions import ValidationError from django.core.validators import MaxValueValidator, MinValueValidator from django.db import models from django.db.models.signals import post_save @@ -94,8 +98,8 @@ class IssueManager(models.Manager): def get_upload_path(instance, filename): if instance.workspace_id is not None: - return f"{instance.workspace.id}/{uuid4().hex}" - return f"user-{uuid4().hex}" + return f"{instance.workspace.id}/{uuid.uuid4().hex}" + return f"user-{uuid.uuid4().hex}" def file_size(value):