Skip to content

Commit ae4ff4f

Browse files
committed
feat: use edited_on block field
1 parent d8de203 commit ae4ff4f

File tree

2 files changed

+4
-22
lines changed

2 files changed

+4
-22
lines changed

cms/djangoapps/contentstore/models.py

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -235,17 +235,7 @@ def update_or_create(
235235
new_values['upstream_block'] = upstream_block
236236
try:
237237
link = cls.objects.get(downstream_usage_key=downstream_usage_key)
238-
# TODO: until we save modified datetime for course xblocks in index, the modified time for links are updated
239-
# everytime a downstream/course block is updated.
240-
# Hardcoding has_changes = True makes sure that the link modified time is updated whenever downstream block
241-
# is updated and this allows us to sort upstream links in course libraries page by recently modified
242-
# downstream blocks: [1].
243-
# pylint: disable=line-too-long
244-
# 1. https://github.com/open-craft/frontend-app-course-authoring/blob/0443d88824095f6f65a3a64b77244af590d4edff/src/course-libraries/ReviewTabContent.tsx#L222-L233
245-
# Ideally, in the future, whenever you modify a downstream XBlock, the code will change the ComponentLink
246-
# "last modified at" time only if something relevant to the upstream sync was modified, like the upstream
247-
# source was changed, or the sync was dismissed (skip the update for this particular version) or accepted.
248-
has_changes = True # change to false once we save modified time in course xblocks
238+
has_changes = False
249239
for key, new_value in new_values.items():
250240
prev_value = getattr(link, key)
251241
if prev_value != new_value:
@@ -320,17 +310,7 @@ def update_or_create(
320310
new_values['upstream_container'] = upstream_container
321311
try:
322312
link = cls.objects.get(downstream_usage_key=downstream_usage_key)
323-
# TODO: until we save modified datetime for course xblocks in index, the modified time for links are updated
324-
# everytime a downstream/course block is updated.
325-
# Hardcoding has_changes = True makes sure that the link modified time is updated whenever downstream block
326-
# is updated and this allows us to sort upstream links in course libraries page by recently modified
327-
# downstream blocks: [1].
328-
# pylint: disable=line-too-long
329-
# 1. https://github.com/open-craft/frontend-app-course-authoring/blob/0443d88824095f6f65a3a64b77244af590d4edff/src/course-libraries/ReviewTabContent.tsx#L222-L233
330-
# Ideally, in the future, whenever you modify a downstream XBlock, the code will change the ComponentLink
331-
# "last modified at" time only if something relevant to the upstream sync was modified, like the upstream
332-
# source was changed, or the sync was dismissed (skip the update for this particular version) or accepted.
333-
has_changes = True # change to false once we save modified time in course xblocks
313+
has_changes = False
334314
for key, new_value in new_values.items():
335315
prev_value = getattr(link, key)
336316
if prev_value != new_value:

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ class implementation returns only:
212212
Fields.access_id: _meili_access_id_from_context_key(block.usage_key.context_key),
213213
Fields.breadcrumbs: [],
214214
}
215+
if hasattr(block, "edited_on"):
216+
block_data[Fields.modified] = block.edited_on.timestamp()
215217
# Get the breadcrumbs (course, section, subsection, etc.):
216218
if block.usage_key.context_key.is_course: # Getting parent is not yet implemented in Learning Core (for libraries).
217219
cur_block = block

0 commit comments

Comments
 (0)