Skip to content

Commit

Permalink
Merge pull request #592 from Ilhasoft/hotfix/repository-log-limit
Browse files Browse the repository at this point in the history
Added repository log limit
  • Loading branch information
Sandro-Meireles authored May 13, 2021
2 parents 0d1e7a8 + 71bedda commit 2d2f3fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bothub/api/v2/repository/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext_lazy as _
from django_filters.rest_framework import DjangoFilterBackend
from django.conf import settings
from drf_yasg2 import openapi
from drf_yasg2.utils import swagger_auto_schema
from rest_framework import mixins, parsers, permissions, status
Expand Down Expand Up @@ -900,6 +901,12 @@ class RepositoryNLPLogViewSet(
filter_class = RepositoryNLPLogFilter
filter_backends = [SearchFilter, DjangoFilterBackend]
search_fields = ["$text", "^text", "=text"]
limit = settings.REPOSITORY_NLP_LOG_LIMIT

def filter_queryset(self, queryset):
queryset = super().filter_queryset(queryset)

return queryset[:self.limit]


class RepositoryEntitiesViewSet(
Expand Down
1 change: 1 addition & 0 deletions bothub/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@
"DEFAULT_METADATA_CLASS": "bothub.api.v2.metadata.Metadata",
}

REPOSITORY_NLP_LOG_LIMIT = env.int("REPOSITORY_NLP_LOG_LIMIT", default=10000)

# cors headers

Expand Down

0 comments on commit 2d2f3fa

Please sign in to comment.