Skip to content

Commit

Permalink
fix: export for analytics and csv (#5815)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablohashescobar authored Oct 12, 2024
1 parent cf53cdf commit 701af73
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
30 changes: 29 additions & 1 deletion apiserver/plane/bgtasks/analytic_plot_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
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
Expand Down Expand Up @@ -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")
Expand Down
3 changes: 1 addition & 2 deletions apiserver/plane/bgtasks/export_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down

0 comments on commit 701af73

Please sign in to comment.