<commit_before>"""DRFES views."""
# Copyright '2015' Solinea, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from rest_framework.generics import ListAPIView
from rest_framework.response import Response
from goldstone.apps.drfes.filters import ElasticFilter
from goldstone.apps.drfes.pagination import ElasticPageNumberPagination
from goldstone.apps.drfes.serializers import ReadOnlyElasticSerializer, \
    SimpleAggSerializer


class ElasticListAPIView(ListAPIView):
    """A view that handles requests for ES search results."""

    serializer_class = ReadOnlyElasticSerializer
    pagination_class = ElasticPageNumberPagination
    filter_backends = (ElasticFilter,)
    reserved_params = []

    class Meta:
        model = None


    def get_queryset(self):
        """Gets a search object from the model."""

        assert self.Meta.model is not None, (
            "'%s' should set the `Meta.model` attribute, "
            "or override the `get_queryset()` method."
            % self.__class__.__name__
        )
        return self.Meta.model.search()

    def get(self, request, *args, **kwargs):
        """Return a response to a GET request."""

        queryset = self.filter_queryset(self.get_queryset())<commit_msg>added page and page_size to the reserved params in ElasticListAPI view<commit_after>"""DRFES views."""
# Copyright '2015' Solinea, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from rest_framework.generics import ListAPIView
from rest_framework.response import Response
from goldstone.apps.drfes.filters import ElasticFilter
from goldstone.apps.drfes.pagination import ElasticPageNumberPagination
from goldstone.apps.drfes.serializers import ReadOnlyElasticSerializer, \
    SimpleAggSerializer


class ElasticListAPIView(ListAPIView):
    """A view that handles requests for ES search results."""

    serializer_class = ReadOnlyElasticSerializer
    pagination_class = ElasticPageNumberPagination
    filter_backends = (ElasticFilter,)
    reserved_params = ['page_size', 'page']

    class Meta:
        model = None


    def get_queryset(self):
        """Gets a search object from the model."""

        assert self.Meta.model is not None, (
            "'%s' should set the `Meta.model` attribute, "
            "or override the `get_queryset()` method."
            % self.__class__.__name__
        )
        return self.Meta.model.search()

    def get(self, request, *args, **kwargs):
        """Return a response to a GET request."""

        queryset = self.filter_queryset(self.get_queryset())
{'fraction_non_alphanumeric': 0.08432036097010716, 'fraction_numerical': 0.0045121263395375075, 'mean_word_length': 3.7042440318302385, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7633166', 'n_tokens_mistral': 961, 'n_tokens_neox': 934, 'n_words': 349}