Example #1
0
def update_search(version_pk, commit, delete_non_commit_files=True):
    """Task to update search indexes

    :param version_pk: Version id to update
    :param commit: Commit that updated index
    :param delete_non_commit_files: Delete files not in commit from index
    """
    version = Version.objects.get(pk=version_pk)

    if version.project.is_type_sphinx:
        page_list = process_all_json_files(version, build_dir=False)
    elif version.project.is_type_mkdocs:
        page_list = process_mkdocs_json(version, build_dir=False)
    else:
        log.error('Unknown documentation type: %s',
                  version.project.documentation_type)
        return

    log_msg = ' '.join([page['path'] for page in page_list])
    log.info("(Search Index) Sending Data: %s [%s]", version.project.slug,
             log_msg)
    index_search_request(
        version=version,
        page_list=page_list,
        commit=commit,
        project_scale=0,
        page_scale=0,
        # Don't index sections to speed up indexing.
        # They aren't currently exposed anywhere.
        section=False,
        delete=delete_non_commit_files,
    )
Example #2
0
def update_search(version_pk, commit):
    """Task to update search indexes

    :param version_pk: Version id to update
    :param commit: Commit that updated index
    """
    version = Version.objects.get(pk=version_pk)

    if version.project.is_type_sphinx:
        page_list = process_all_json_files(version, build_dir=False)
    elif version.project.is_type_mkdocs:
        page_list = process_mkdocs_json(version, build_dir=False)
    else:
        log.error('Unknown documentation type: %s',
                  version.project.documentation_type)
        return

    log_msg = ' '.join([page['path'] for page in page_list])
    log.info("(Search Index) Sending Data: %s [%s]", version.project.slug,
             log_msg)
    index_search_request(
        version=version,
        page_list=page_list,
        commit=commit,
        project_scale=0,
        page_scale=0,
        # Don't index sections to speed up indexing.
        # They aren't currently exposed anywhere.
        section=False,
    )
Example #3
0
def update_search(version_pk, commit):

    version = Version.objects.get(pk=version_pk)

    if version.project.is_type_sphinx:
        page_list = process_all_json_files(version, build_dir=False)
    elif version.project.is_type_mkdocs:
        page_list = process_mkdocs_json(version, build_dir=False)
    else:
        log.error('Unknown documentation type: %s' %
                  version.project.documentation_type)
        return

    log_msg = ' '.join([page['path'] for page in page_list])
    log.info("(Search Index) Sending Data: %s [%s]" %
             (version.project.slug, log_msg))
    index_search_request(
        version=version,
        page_list=page_list,
        commit=commit,
        project_scale=0,
        page_scale=0,
        # Don't index sections to speed up indexing.
        # They aren't currently exposed anywhere.
        section=False,
    )
Example #4
0
def update_search(version_pk, commit, delete_non_commit_files=True):
    """
    Task to update search indexes.

    :param version_pk: Version id to update
    :param commit: Commit that updated index
    :param delete_non_commit_files: Delete files not in commit from index
    """
    version = Version.objects.get(pk=version_pk)

    page_list = process_all_json_files(version, build_dir=False)

    log_msg = ' '.join([page['path'] for page in page_list])
    log.info(
        '(Search Index) Sending Data: %s [%s]',
        version.project.slug,
        log_msg,
    )
    index_search_request(
        version=version,
        page_list=page_list,
        commit=commit,
        project_scale=0,
        page_scale=0,
        # Don't index sections to speed up indexing.
        # They aren't currently exposed anywhere.
        section=False,
        delete=delete_non_commit_files,
    )
Example #5
0
    def handle(self, *args, **options):
        '''
        Build/index all versions or a single project's version
        '''
        project = options['project']

        if project:
            queryset = Version.objects.public(project__slug=project)
            log.info("Building all versions for %s" % project)
        elif getattr(settings, 'INDEX_ONLY_LATEST', True):
            queryset = Version.objects.public().filter(slug=LATEST)
        else:
            queryset = Version.objects.public()
        for version in queryset:
            log.info("Reindexing %s" % version)
            try:
                commit = version.project.vcs_repo(version.slug).commit
            except:
                # This will happen on prod
                commit = None
            try:
                page_list = parse_json.process_all_json_files(version,
                                                              build_dir=False)
                index_search_request(version=version,
                                     page_list=page_list,
                                     commit=commit,
                                     project_scale=0,
                                     page_scale=0,
                                     section=False,
                                     delete=False)
            except Exception:
                log.error('Build failed for %s' % version, exc_info=True)
    def handle(self, *args, **options):
        '''
        Build/index all versions or a single project's version
        '''
        project = options['project']

        if project:
            queryset = Version.objects.public(project__slug=project)
            log.info("Building all versions for %s" % project)
        elif getattr(settings, 'INDEX_ONLY_LATEST', True):
            queryset = Version.objects.public().filter(slug=LATEST)
        else:
            queryset = Version.objects.public()
        for version in queryset:
            log.info("Reindexing %s" % version)
            try:
                commit = version.project.vcs_repo(version.slug).commit
            except:
                # This will happen on prod
                commit = None
            try:
                page_list = parse_json.process_all_json_files(version, build_dir=False)
                index_search_request(
                    version=version, page_list=page_list, commit=commit,
                    project_scale=0, page_scale=0, section=False, delete=False)
            except Exception:
                log.error('Build failed for %s' % version, exc_info=True)