Skip to content

Commit

Permalink
refactor: order collections by primary key
Browse files Browse the repository at this point in the history
  • Loading branch information
navinkarkera committed Aug 23, 2024
1 parent 2a0bc53 commit cdc7dd2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions openedx_learning/apps/authoring/collections/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def get_learning_package_collections(learning_package_id: int) -> QuerySet[Colle
"""
return Collection.objects \
.filter(learning_package_id=learning_package_id, enabled=True) \
.select_related("learning_package")
.select_related("learning_package") \
.order_by('pk')


def get_collections(enabled: bool | None = None) -> QuerySet[Collection]:
Expand All @@ -88,4 +89,4 @@ def get_collections(enabled: bool | None = None) -> QuerySet[Collection]:
qs = Collection.objects.all()
if enabled is not None:
qs = qs.filter(enabled=enabled)
return qs.select_related("learning_package")
return qs.select_related("learning_package").order_by('pk')
4 changes: 2 additions & 2 deletions tests/openedx_learning/apps/authoring/collections/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def test_get_all_collections(self):
self.collection2,
self.collection3,
self.disabled_collection,
], ordered=False)
], ordered=True)

def test_get_all_enabled_collections(self):
"""
Expand All @@ -131,7 +131,7 @@ def test_get_all_enabled_collections(self):
self.collection1,
self.collection2,
self.collection3,
], ordered=False)
], ordered=True)

def test_get_all_disabled_collections(self):
"""
Expand Down

0 comments on commit cdc7dd2

Please sign in to comment.