Skip to content

Commit b6f2d98

Browse files
committed
refactor: use new version of openedx-learning to use less queries when obtaining collection children
1 parent 5e771ce commit b6f2d98

File tree

7 files changed

+8
-18
lines changed

7 files changed

+8
-18
lines changed

openedx/core/djangoapps/content/search/documents.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -486,18 +486,8 @@ def searchable_doc_for_collection(
486486
if collection:
487487
assert collection.key == collection_key
488488

489-
draft_num_children = 0
490-
published_num_children = 0
491-
492-
# Count draft and published children
493-
for entity in collection.entities.all():
494-
draft = authoring_api.get_draft_version(entity.id)
495-
published = authoring_api.get_published_version(entity.id)
496-
497-
if draft:
498-
draft_num_children += 1
499-
if published:
500-
published_num_children += 1
489+
draft_num_children = authoring_api.get_drafts(collection.entities).count()
490+
published_num_children = authoring_api.get_published(collection.entities).count()
501491

502492
doc.update({
503493
Fields.context_key: str(library_key),

requirements/constraints.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ optimizely-sdk<5.0
139139
# Date: 2023-09-18
140140
# pinning this version to avoid updates while the library is being developed
141141
# Issue for unpinning: https://github.com/openedx/edx-platform/issues/35269
142-
openedx-learning==0.16.3
142+
openedx-learning==0.17.0
143143

144144
# Date: 2023-11-29
145145
# Open AI version 1.0.0 dropped support for openai.ChatCompletion which is currently in use in enterprise.

requirements/edx/base.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ openedx-filters==1.11.0
827827
# -r requirements/edx/kernel.in
828828
# lti-consumer-xblock
829829
# ora2
830-
openedx-learning==0.16.3
830+
openedx-learning @ git+https://github.com/open-craft/openedx-learning.git@chris/FAL-3921-get-drafts-and-get-published
831831
# via
832832
# -c requirements/edx/../constraints.txt
833833
# -r requirements/edx/kernel.in

requirements/edx/development.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,7 @@ openedx-filters==1.11.0
13811381
# -r requirements/edx/testing.txt
13821382
# lti-consumer-xblock
13831383
# ora2
1384-
openedx-learning==0.16.3
1384+
openedx-learning @ git+https://github.com/open-craft/openedx-learning.git@chris/FAL-3921-get-drafts-and-get-published
13851385
# via
13861386
# -c requirements/edx/../constraints.txt
13871387
# -r requirements/edx/doc.txt

requirements/edx/doc.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ openedx-filters==1.11.0
990990
# -r requirements/edx/base.txt
991991
# lti-consumer-xblock
992992
# ora2
993-
openedx-learning==0.16.3
993+
openedx-learning @ git+https://github.com/open-craft/openedx-learning.git@chris/FAL-3921-get-drafts-and-get-published
994994
# via
995995
# -c requirements/edx/../constraints.txt
996996
# -r requirements/edx/base.txt

requirements/edx/kernel.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ openedx-calc # Library supporting mathematical calculatio
119119
openedx-django-require
120120
openedx-events # Open edX Events from Hooks Extension Framework (OEP-50)
121121
openedx-filters # Open edX Filters from Hooks Extension Framework (OEP-50)
122-
openedx-learning # Open edX Learning core (experimental)
122+
git+https://github.com/open-craft/openedx-learning.git@chris/FAL-3921-get-drafts-and-get-published#egg=openedx-learning # Open edX Learning core (experimental)
123123
openedx-mongodbproxy
124124
openedx-django-wiki
125125
path

requirements/edx/testing.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ openedx-filters==1.11.0
10411041
# -r requirements/edx/base.txt
10421042
# lti-consumer-xblock
10431043
# ora2
1044-
openedx-learning==0.16.3
1044+
openedx-learning @ git+https://github.com/open-craft/openedx-learning.git@chris/FAL-3921-get-drafts-and-get-published
10451045
# via
10461046
# -c requirements/edx/../constraints.txt
10471047
# -r requirements/edx/base.txt

0 commit comments

Comments
 (0)