Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

fix: export for analytics and csv (#5815)

Nikhil701af734cdf7
diff --git a/apiserver/plane/bgtasks/analytic_plot_export.py b/apiserver/plane/bgtasks/analytic_plot_export.py
index 0de64603dc..7d78b89d06 100644
--- a/apiserver/plane/bgtasks/analytic_plot_export.py
+++ b/apiserver/plane/bgtasks/analytic_plot_export.py
@@ -10,6 +10,9 @@ from celery import shared_task
from django.core.mail import EmailMultiAlternatives, get_connection
from django.template.loader import render_to_string
from django.utils.html import strip_tags
+from django.db.models import Q, Case, Value, When
+from django.db import models
+from django.db.models.functions import Concat
# Module imports
from plane.db.models import Issue
@@ -84,7 +87,32 @@ def get_assignee_details(slug, filters):
"""Fetch assignee details if required."""
return (
Issue.issue_objects.filter(
- workspace__slug=slug, **filters, assignees__avatar__isnull=False
+ Q(
+ Q(assignees__avatar__isnull=False)
+ | Q(assignees__avatar_asset__isnull=False)
+ ),
+ workspace__slug=slug,
+ **filters,
+ )
+ .annotate(
+ assignees__avatar_url=Case(
+ # If `avatar_asset` exists, use it to generate the asset URL
+ When(
+ assignees__avatar_asset__isnull=False,
+ then=Concat(
+ Value("/api/assets/v2/static/"),
+ "assignees__avatar_asset", # Assuming avatar_asset has an id or relevant field
+ Value("/"),
+ ),
+ ),
+ # If `avatar_asset` is None, fall back to using `avatar` field directly
+ When(
+ assignees__avatar_asset__isnull=True,
+ then="assignees__avatar",
+ ),
+ default=Value(None),
+ output_field=models.CharField(),
+ )
)
.distinct("assignees__id")
.order_by("assignees__id")
diff --git a/apiserver/plane/bgtasks/export_task.py b/apiserver/plane/bgtasks/export_task.py
index e671608d9d..b88aad3271 100644
--- a/apiserver/plane/bgtasks/export_task.py
+++ b/apiserver/plane/bgtasks/export_task.py
@@ -105,7 +105,6 @@ def upload_to_s3(zip_file, workspace_id, token_id, slug):
ExpiresIn=expires_in,
)
else:
-
# If endpoint url is present, use it
if settings.AWS_S3_ENDPOINT_URL:
s3 = boto3.client(
@@ -129,7 +128,7 @@ def upload_to_s3(zip_file, workspace_id, token_id, slug):
zip_file,
settings.AWS_STORAGE_BUCKET_NAME,
file_name,
- ExtraArgs={"ACL": "public-read", "ContentType": "application/zip"},
+ ExtraArgs={"ContentType": "application/zip"},
)
# Generate presigned url for the uploaded file