Skip to content

Commit 1367939

Browse files
committed
fix: use order_by(version_num) instead of filter(version_num=1) in creation entries
1 parent 2f48587 commit 1367939

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

openedx/core/djangoapps/content_libraries/api/blocks.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def get_library_component_creation_entry(
391391
Return the creation entry for a library component.
392392
393393
This is a single LibraryHistoryEntry representing the moment the
394-
component was first created (version_num=1). Returns None if the component
394+
component was first created. Returns None if the component
395395
has no versions yet.
396396
397397
Raises ContentLibraryBlockNotFound if the component does not exist.
@@ -401,9 +401,10 @@ def get_library_component_creation_entry(
401401
except ObjectDoesNotExist as exc:
402402
raise ContentLibraryBlockNotFound(usage_key) from exc
403403

404+
# TODO: replace with component.versioning.earliest once VersioningHelper exposes that helper.
404405
first_version = (
405406
component.publishable_entity.versions
406-
.filter(version_num=1)
407+
.order_by('version_num')
407408
.select_related("created_by__profile")
408409
.first()
409410
)

openedx/core/djangoapps/content_libraries/api/containers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,13 +813,14 @@ def get_library_container_creation_entry(
813813
[ 🛑 UNSTABLE ] Return the creation entry for a library container.
814814
815815
This is a single LibraryHistoryEntry representing the moment the container
816-
was first created (version_num=1). Returns None if the container has no
816+
was first created. Returns None if the container has no
817817
versions yet.
818818
"""
819819
container = get_container_from_key(container_key)
820+
# TODO: replace with container.versioning.earliest once VersioningHelper exposes that helper.
820821
first_version = (
821822
container.publishable_entity.versions
822-
.filter(version_num=1)
823+
.order_by('version_num')
823824
.select_related("created_by__profile")
824825
.first()
825826
)

0 commit comments

Comments
 (0)