<commit_before>from rest_framework import generics, response

from nodeconductor.events import elasticsearch_client


class EventListView(generics.GenericAPIView):

    def list(self, request, *args, **kwargs):
        order_by = request.GET.get('o', '-@timestamp')
        elasticsearch_list = elasticsearch_client.ElasticsearchResultList(user=request.user, sort=order_by)

        page = self.paginate_queryset(elasticsearch_list)
        if page is not None:
            return self.get_paginated_response(page)
        return response.Response(elasticsearch_list)

    def get(self, request, *args, **kwargs):
        return self.list(request, *args, **kwargs)<commit_msg>Add filtering to view (nc-463)<commit_after>from rest_framework import generics, response

from nodeconductor.events import elasticsearch_client


class EventListView(generics.GenericAPIView):

    def list(self, request, *args, **kwargs):
        order_by = request.GET.get('o', '-@timestamp')
        event_types = request.GET.getlist('event_type')
        search_text = request.GET.get('search_text')
        elasticsearch_list = elasticsearch_client.ElasticsearchResultList(
            user=request.user, sort=order_by, event_types=event_types, search_text=search_text)

        page = self.paginate_queryset(elasticsearch_list)
        if page is not None:
            return self.get_paginated_response(page)
        return response.Response(elasticsearch_list)

    def get(self, request, *args, **kwargs):
        return self.list(request, *args, **kwargs)
{'fraction_non_alphanumeric': 0.09928617780661908, 'fraction_numerical': 0.001946787800129786, 'mean_word_length': 4.055737704918033, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6692982', 'n_tokens_mistral': 443, 'n_tokens_neox': 429, 'n_words': 94}