コード例 #1
0
ファイル: tasks.py プロジェクト: CrRinko/edx-platform
def update_search_index(course_id, triggered_time_isoformat):
    """ Updates course search index. """
    try:
        course_key = CourseKey.from_string(course_id)
        triggered_time = datetime.strptime(
            # remove the +00:00 from the end of the formats generated within the system
            triggered_time_isoformat.split('+')[0],
            "%Y-%m-%dT%H:%M:%S.%f"
        ).replace(tzinfo=UTC)
        CoursewareSearchIndexer.index_course(modulestore(), course_key, triggered_at=triggered_time)

    except SearchIndexingError as exc:
        LOGGER.error('Search indexing error for complete course %s - %s', course_id, unicode(exc))
    else:
        LOGGER.debug('Search indexing successful for complete course %s', course_id)
コード例 #2
0
 def index_recent_changes(self, store, since_time):
     """ index course using recent changes """
     trigger_time = datetime.now(UTC)
     return CoursewareSearchIndexer.index_course(store,
                                                 self.course.id,
                                                 triggered_at=trigger_time,
                                                 reindex_age=(trigger_time -
                                                              since_time))
コード例 #3
0
ファイル: tasks.py プロジェクト: rmoorman/edx-platform
def update_search_index(course_id, triggered_time_isoformat):
    """ Updates course search index. """
    try:
        course_key = CourseKey.from_string(course_id)
        triggered_time = datetime.strptime(
            # remove the +00:00 from the end of the formats generated within the system
            triggered_time_isoformat.split('+')[0],
            "%Y-%m-%dT%H:%M:%S.%f").replace(tzinfo=UTC)
        CoursewareSearchIndexer.index_course(modulestore(),
                                             course_key,
                                             triggered_at=triggered_time)

    except SearchIndexingError as exc:
        LOGGER.error('Search indexing error for complete course %s - %s',
                     course_id, unicode(exc))
    else:
        LOGGER.debug('Search indexing successful for complete course %s',
                     course_id)
コード例 #4
0
 def index_recent_changes(self, store, since_time):
     """ index course using recent changes """
     trigger_time = datetime.now(UTC)
     return CoursewareSearchIndexer.index_course(
         store,
         self.course.id,
         triggered_at=trigger_time,
         reindex_age=(trigger_time - since_time)
     )