def handle(self, *args, **options): """Build/index all versions or a single project's version""" project = options['project'] queryset = Version.objects.all() if project: queryset = queryset.filter(project__slug=project) if not queryset.exists(): raise CommandError( 'No project with slug: {slug}'.format(slug=project)) log.info("Building all versions for %s", project) elif getattr(settings, 'INDEX_ONLY_LATEST', True): queryset = queryset.filter(slug=LATEST) for version in queryset: log.info("Reindexing %s", version) try: commit = version.project.vcs_repo(version.slug).commit except: # pylint: disable=bare-except # An exception can be thrown here in production, but it's not # documented what the exception here is commit = None try: update_search(version.pk, commit, delete_non_commit_files=False) except Exception: log.exception('Reindex failed for {}'.format(version))
def handle(self, *args, **options): """Build/index all versions or a single project's version""" project = options['project'] queryset = Version.objects.all() if project: queryset = queryset.filter(project__slug=project) if not queryset.exists(): raise CommandError( 'No project with slug: {slug}'.format(slug=project)) log.info("Building all versions for %s" % project) elif getattr(settings, 'INDEX_ONLY_LATEST', True): queryset = queryset.filter(slug=LATEST) 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: update_search(version.pk, commit, delete_non_commit_files=False) except Exception: log.error('Reindex 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'] queryset = Version.objects.all() if project: queryset = queryset.filter(project__slug=project) if not queryset.exists(): raise CommandError( 'No project with slug: {slug}'.format(slug=project)) log.info("Building all versions for %s", project) elif getattr(settings, 'INDEX_ONLY_LATEST', True): queryset = queryset.filter(slug=LATEST) for version in queryset: log.info("Reindexing %s", version) try: commit = version.project.vcs_repo(version.slug).commit except: # noqa # An exception can be thrown here in production, but it's not # documented what the exception here is commit = None try: update_search(version.pk, commit, delete_non_commit_files=False) except Exception: log.exception('Reindex failed for %s', version)
def handle(self, *args, **options): """Build/index all versions or a single project's version""" project = options['project'] queryset = Version.objects.public() if project: queryset = queryset.filter(project__slug=project) if not queryset.exists(): raise CommandError( 'No project with slug: {slug}'.format(slug=project)) log.info("Building all versions for %s" % project) elif getattr(settings, 'INDEX_ONLY_LATEST', True): queryset = queryset.filter(slug=LATEST) 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: update_search(version.pk, commit, delete_non_commit_files=False) except Exception: log.error('Reindex failed for %s' % version, exc_info=True)