Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix/recurrence_group_order] queryset to order_by to preseve data order in recurrence_group #5428

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion engine/common/api_helpers/custom_fields.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import timedelta

from django.core.exceptions import ObjectDoesNotExist
from django.db.models import Case, When
from drf_spectacular.utils import extend_schema_field
from rest_framework import fields, serializers
from rest_framework.exceptions import ValidationError
Expand Down Expand Up @@ -104,7 +105,7 @@ def to_internal_value(self, data):
if not request or not queryset:
return None

users = queryset.filter(organization=request.user.organization, public_primary_key__in=data).distinct()
users = queryset.filter(organization=request.user.organization, public_primary_key__in=data).distinct().order_by(Case(*[When(public_primary_key=pk, then=pos) for pos, pk in enumerate(data)]))
users_ppk = set(u.public_primary_key for u in users)
data_set = set(data)

Expand Down