Skip to content

Commit b7dc62e

Browse files
committed
fixup! feat: Add the command to schedule the celery task for populating the index.
1 parent b956962 commit b7dc62e

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

openedx/core/djangoapps/content/search/management/commands/reindex_studio.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,19 @@
99
indexes LMS (published) courses in ElasticSearch.
1010
"""
1111

12+
import logging
1213
from django.core.management import BaseCommand, CommandError
1314

1415
from ... import api
1516
from ...tasks import rebuild_index_incremental
1617

1718

19+
log = logging.getLogger(__name__)
20+
21+
1822
class Command(BaseCommand):
1923
"""
20-
Queue incremental population of the Meilisearch search index for Studio.
24+
Add all course and library content to the Studio search index.
2125
2226
This enqueues a Celery task that incrementally indexes all courses and
2327
libraries. Progress is tracked via IncrementalIndexCompleted, so the task
@@ -27,7 +31,7 @@ class Command(BaseCommand):
2731
(runs automatically on ./manage.py cms migrate).
2832
"""
2933

30-
help = "Queue incremental population of the Studio Meilisearch search index via Celery."
34+
help = "Add all course and library content to the Studio search index."
3135

3236
def add_arguments(self, parser):
3337
# Removed flags — provide clear error messages for operators with old automation.
@@ -69,7 +73,7 @@ def handle(self, *args, **options):
6973
)
7074

7175
if options["incremental"]:
72-
raise CommandError(
76+
log.warning(
7377
"The --incremental flag has been removed. "
7478
"Incremental population is now the default behavior of this command."
7579
)

openedx/core/djangoapps/content/search/tests/test_reindex_cmd.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,16 @@ def test_init_flag_removed(self):
4949
with pytest.raises(CommandError, match="--init flag has been removed"):
5050
call_command("reindex_studio", "--init")
5151

52-
def test_incremental_flag_removed(self):
53-
"""Passing --incremental raises a clear error."""
54-
with pytest.raises(CommandError, match="--incremental flag has been removed"):
55-
call_command("reindex_studio", "--incremental")
52+
@patch("openedx.core.djangoapps.content.search.tasks.rebuild_index_incremental.delay")
53+
@patch("openedx.core.djangoapps.content.search.management.commands.reindex_studio.log")
54+
def test_incremental_flag_accepted_with_warning(self, mock_log, mock_delay):
55+
"""Passing --incremental logs a warning but still enqueues the task."""
56+
mock_delay.return_value = Mock(id="fake-task-id")
57+
58+
call_command("reindex_studio", "--incremental")
59+
60+
mock_log.warning.assert_called_once()
61+
mock_delay.assert_called_once_with()
5662

5763

5864
@skip_unless_cms

0 commit comments

Comments
 (0)