Skip to content

Commit

Permalink
revert: fixes in rebuild index
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisChV committed Sep 10, 2024
1 parent 0c5e572 commit 3180f76
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions openedx/core/djangoapps/content/search/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from meilisearch.models.task import TaskInfo
from opaque_keys.edx.keys import UsageKey
from opaque_keys.edx.locator import LibraryLocatorV2
from openedx_learning.api.authoring_models import Collection
from openedx_learning.api import authoring as authoring_api
from common.djangoapps.student.roles import GlobalStaff
from rest_framework.request import Request
from common.djangoapps.student.role_helpers import get_course_roles
Expand Down Expand Up @@ -298,8 +298,7 @@ def rebuild_index(status_cb: Callable[[str], None] | None = None) -> None:

# Get the list of collections
status_cb("Counting collections...")
collections = Collection.objects.filter(enabled=True).select_related("learning_package").order_by('pk')
num_collections = collections.count()
num_collections = authoring_api.get_collections().count()

# Some counters so we can track our progress as indexing progresses:
num_contexts = num_courses + num_libraries + num_collections
Expand Down Expand Up @@ -460,7 +459,7 @@ def index_collection_batch(batch, num_contexts_done) -> int:
return num_contexts_done

# To reduce memory usage on large instances, split up the Collections into pages of 100 collections:
paginator = Paginator(collections, 100)
paginator = Paginator(authoring_api.get_collections(enabled=True), 100)
for p in paginator.page_range:
num_contexts_done = index_collection_batch(paginator.page(p).object_list, num_contexts_done)

Expand Down

0 comments on commit 3180f76

Please sign in to comment.