Skip to content

Commit

Permalink
Merge pull request #880 from uktrade/LTD-1543-order-parties-uniquely
Browse files Browse the repository at this point in the history
Additionally order by id so not to break pagination
  • Loading branch information
wkeeling authored Dec 9, 2021
2 parents b843af5 + 9d4f92a commit 5d03586
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion api/data_workspace/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ class PartyListView(viewsets.ReadOnlyModelViewSet):
authentication_classes = (DataWorkspaceOnlyAuthentication,)
serializer_class = PartyViewSerializer
pagination_class = LimitOffsetPagination
queryset = Party.objects.all()
# We ensure that parties with the same name always come out
# in the same order by additionally ordering by created_at
# and by id. If just name is used, the order is non-deterministic
# when multiple parties have the same name. This can mean the
# same party being emitted on different pages, causing
# primary key violations in Data Workspace.
queryset = Party.objects.order_by("name", "created_at", "id")


class QueueListView(viewsets.ReadOnlyModelViewSet):
Expand Down

0 comments on commit 5d03586

Please sign in to comment.