Exemplo n.º 1
0
    def handle(self, *args, **options):
        """
        By convention set by django developers, this method actually executes command's actions.
        So, there could be no better docstring than emphasize this once again.
        """
        if len(args) == 0 and not options.get('all', False):
            raise CommandError(
                u"reindex_library requires one or more arguments: <library_id>"
            )

        store = modulestore()

        if options.get('all', False):
            if query_yes_no(self.CONFIRMATION_PROMPT, default="no"):
                library_keys = [
                    library.location.library_key.replace(branch=None)
                    for library in store.get_libraries()
                ]
            else:
                return
        else:
            library_keys = map(self._parse_library_key, args)

        for library_key in library_keys:
            LibrarySearchIndexer.do_library_reindex(store, library_key)
Exemplo n.º 2
0
    def handle(self, *args, **options):
        """
        By convention set by django developers, this method actually executes command's actions.
        So, there could be no better docstring than emphasize this once again.
        """
        if (not options['library_ids']
                and not options['all']) or (options['library_ids']
                                            and options['all']):
            raise CommandError(
                u"reindex_library requires one or more <library_id>s or the --all flag."
            )

        store = modulestore()

        if options['all']:
            if query_yes_no(self.CONFIRMATION_PROMPT, default="no"):
                library_keys = [
                    library.location.library_key.replace(branch=None)
                    for library in store.get_libraries()
                ]
            else:
                return
        else:
            library_keys = list(
                map(self._parse_library_key, options['library_ids']))

        for library_key in library_keys:
            print(u"Indexing library {}".format(library_key))
            LibrarySearchIndexer.do_library_reindex(store, library_key)
Exemplo n.º 3
0
def update_library_index(library_id, triggered_time_isoformat):
    """ Updates course search index. """
    try:
        library_key = CourseKey.from_string(library_id)
        LibrarySearchIndexer.index(modulestore(), library_key, triggered_at=(_parse_time(triggered_time_isoformat)))

    except SearchIndexingError as exc:
        LOGGER.error(u'Search indexing error for library %s - %s', library_id, text_type(exc))
    else:
        LOGGER.debug(u'Search indexing successful for library %s', library_id)
Exemplo n.º 4
0
def update_library_index(library_id, triggered_time_isoformat):
    """ Updates course search index. """
    try:
        library_key = CourseKey.from_string(library_id)
        LibrarySearchIndexer.index(modulestore(), library_key, triggered_at=(_parse_time(triggered_time_isoformat)))

    except SearchIndexingError as exc:
        LOGGER.error(u'Search indexing error for library %s - %s', library_id, text_type(exc))
    else:
        LOGGER.debug(u'Search indexing successful for library %s', library_id)
Exemplo n.º 5
0
def listen_for_library_update(sender, library_key, **kwargs):  # pylint: disable=unused-argument
    """
    Receives signal and kicks off celery task to update search index
    """
    # import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
    from .tasks import update_library_index
    if LibrarySearchIndexer.indexing_is_enabled():
        update_library_index.delay(unicode(library_key), datetime.now(UTC).isoformat())
    def handle(self, *args, **options):
        """
        By convention set by django developers, this method actually executes command's actions.
        So, there could be no better docstring than emphasize this once again.
        """
        if len(args) == 0 and not options.get('all', False):
            raise CommandError(u"reindex_library requires one or more arguments: <library_id>")

        store = modulestore()

        if options.get('all', False):
            if query_yes_no(self.CONFIRMATION_PROMPT, default="no"):
                library_keys = [library.location.library_key.replace(branch=None) for library in store.get_libraries()]
            else:
                return
        else:
            library_keys = map(self._parse_library_key, args)

        for library_key in library_keys:
            LibrarySearchIndexer.do_library_reindex(store, library_key)
Exemplo n.º 7
0
    def handle(self, *args, **options):
        """
        By convention set by django developers, this method actually executes command's actions.
        So, there could be no better docstring than emphasize this once again.
        """
        if (not options['library_ids'] and not options['all']) or (options['library_ids'] and options['all']):
            raise CommandError(u"reindex_library requires one or more <library_id>s or the --all flag.")

        store = modulestore()

        if options['all']:
            if query_yes_no(self.CONFIRMATION_PROMPT, default="no"):
                library_keys = [library.location.library_key.replace(branch=None) for library in store.get_libraries()]
            else:
                return
        else:
            library_keys = map(self._parse_library_key, options['library_ids'])

        for library_key in library_keys:
            print("Indexing library {}".format(library_key))
            LibrarySearchIndexer.do_library_reindex(store, library_key)
Exemplo n.º 8
0
 def reindex_library(self, store):
     """ kick off complete reindex of the course """
     return LibrarySearchIndexer.do_library_reindex(store, self.library.location.library_key)
Exemplo n.º 9
0
 def reindex_library(self, store):
     """ kick off complete reindex of the course """
     return LibrarySearchIndexer.do_library_reindex(store, self.library.location.library_key)