fix: analytics tab for private bucket (#5814)
This commit is contained in:
parent
6490ace7c7
commit
cf53cdf6ba
2 changed files with 27 additions and 7 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
# Django imports
|
# Django imports
|
||||||
from django.db.models import Count, F, Sum
|
from django.db.models import Count, F, Sum, Q
|
||||||
from django.db.models.functions import ExtractMonth
|
from django.db.models.functions import ExtractMonth
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.db.models.functions import Concat
|
from django.db.models.functions import Concat
|
||||||
|
|
@ -121,9 +121,32 @@ class AnalyticsEndpoint(BaseAPIView):
|
||||||
if x_axis in ["assignees__id"] or segment in ["assignees__id"]:
|
if x_axis in ["assignees__id"] or segment in ["assignees__id"]:
|
||||||
assignee_details = (
|
assignee_details = (
|
||||||
Issue.issue_objects.filter(
|
Issue.issue_objects.filter(
|
||||||
|
Q(
|
||||||
|
Q(assignees__avatar__isnull=False)
|
||||||
|
| Q(assignees__avatar_asset__isnull=False)
|
||||||
|
),
|
||||||
workspace__slug=slug,
|
workspace__slug=slug,
|
||||||
**filters,
|
**filters,
|
||||||
assignees__avatar_url__isnull=False,
|
)
|
||||||
|
.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(),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
.order_by("assignees__id")
|
.order_by("assignees__id")
|
||||||
.distinct("assignees__id")
|
.distinct("assignees__id")
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ class CycleIssueViewSet(BaseViewSet):
|
||||||
)
|
)
|
||||||
.annotate(
|
.annotate(
|
||||||
attachment_count=FileAsset.objects.filter(
|
attachment_count=FileAsset.objects.filter(
|
||||||
entity_identifier=OuterRef("id"),
|
issue_id=OuterRef("id"),
|
||||||
entity_type=FileAsset.EntityTypeContext.ISSUE_ATTACHMENT,
|
entity_type=FileAsset.EntityTypeContext.ISSUE_ATTACHMENT,
|
||||||
)
|
)
|
||||||
.order_by()
|
.order_by()
|
||||||
|
|
@ -247,10 +247,7 @@ class CycleIssueViewSet(BaseViewSet):
|
||||||
workspace__slug=slug, project_id=project_id, pk=cycle_id
|
workspace__slug=slug, project_id=project_id, pk=cycle_id
|
||||||
)
|
)
|
||||||
|
|
||||||
if (
|
if cycle.end_date is not None and cycle.end_date < timezone.now():
|
||||||
cycle.end_date is not None
|
|
||||||
and cycle.end_date < timezone.now()
|
|
||||||
):
|
|
||||||
return Response(
|
return Response(
|
||||||
{
|
{
|
||||||
"error": "The Cycle has already been completed so no new issues can be added"
|
"error": "The Cycle has already been completed so no new issues can be added"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue