<commit_before>from rest_framework import filters
from django.db.models.sql.constants import QUERY_TERMS
from haystack.query import SearchQuerySet
from haystack.inputs import Exact
import gc

from django.db.models import Q
from django_filters import CharFilter
from django_filters import Filter, FilterSet, NumberFilter, DateFilter, BooleanFilter

VALID_LOOKUP_TYPES = sorted(QUERY_TERMS)


class SearchFilter(filters.BaseFilterBackend):
    def filter_queryset(self, request, queryset, view):

        query = request.query_params.get('q', None)
        exact = request.query_params.get('exact', None)

        if query:
            # always match text exactly
            if exact: query = Exact(query)

            search_queryset = SearchQuerySet()
            query_fields = request.query_params.get('q_fields')<commit_msg>fix for bug when using budget_period_start and budget_period_end together<commit_after>import uuid
import gc

from rest_framework import filters
from haystack.query import SearchQuerySet
from haystack.inputs import Exact

from django.db.models.sql.constants import QUERY_TERMS
from django.db.models import Q
from django_filters import CharFilter
from django_filters import Filter, FilterSet, NumberFilter, DateFilter, BooleanFilter

VALID_LOOKUP_TYPES = sorted(QUERY_TERMS)


class SearchFilter(filters.BaseFilterBackend):
    def filter_queryset(self, request, queryset, view):

        query = request.query_params.get('q', None)
        exact = request.query_params.get('exact', None)

        if query:
            # always match text exactly
            if exact: query = Exact(query)

            search_queryset = SearchQuerySet()
            query_fields = request.query_params.get('q_fields')
{'fraction_non_alphanumeric': 0.06940427993059572, 'fraction_numerical': 0.0, 'mean_word_length': 4.0, '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': '3488339', 'n_tokens_mistral': 481, 'n_tokens_neox': 475, 'n_words': 135}