<commit_before>from django.core.mail import send_mass_mail
from django.conf import settings
from django.template.loader import render_to_string
from rest_framework import exceptions, mixins, viewsets

from api_v3.models import Action, Comment, Profile, Ticket
from api_v3.misc.queue import queue
from api_v3.serializers import TicketSerializer
from .support import JSONApiEndpoint


class TicketsEndpoint(
        JSONApiEndpoint,
        mixins.CreateModelMixin,
        mixins.UpdateModelMixin,
        viewsets.ReadOnlyModelViewSet):

    queryset = Ticket.objects.all()
    serializer_class = TicketSerializer
    ordering_fields = ('created_at', 'deadline_at')
    filter_fields = {
        'created_at': ['range'],
        'deadline_at': ['range'],
        'status': ['in'],
        'kind': ['exact'],
        'country': ['exact'],
        'requester': ['exact'],
        'responders__user': ['exact', 'isnull']
    }

    EMAIL_SUBJECT = 'A new ticket was requested, ID: {}'

    def get_queryset(self):
        queryset = super(TicketsEndpoint, self).get_queryset()

        if self.request.user.is_superuser:
            return queryset

        # If this is anonymous, for some reason DRF evaluates the
        # authentication after the queryset
        if not self.request.user.is_active:
            return queryset.none()

        return Ticket.filter_by_user(self.request.user, queryset)

    def filter_queryset(self, queryset):
        """Patch filtering method to use the search implementation."""
        filters = self.extract_filter_params(self.request)
        filtered = super(TicketsEndpoint, self).filter_queryset(queryset)
<commit_msg>Updated created_at filter expressions.<commit_after>from django.core.mail import send_mass_mail
from django.conf import settings
from django.template.loader import render_to_string
from rest_framework import exceptions, mixins, viewsets

from api_v3.models import Action, Comment, Profile, Ticket
from api_v3.misc.queue import queue
from api_v3.serializers import TicketSerializer
from .support import JSONApiEndpoint


class TicketsEndpoint(
        JSONApiEndpoint,
        mixins.CreateModelMixin,
        mixins.UpdateModelMixin,
        viewsets.ReadOnlyModelViewSet):

    queryset = Ticket.objects.all()
    serializer_class = TicketSerializer
    ordering_fields = ('created_at', 'deadline_at')
    filter_fields = {
        'created_at': ['range', 'gte', 'lte'],
        'deadline_at': ['range', 'gte', 'lte'],
        'status': ['in'],
        'kind': ['exact'],
        'country': ['exact'],
        'requester': ['exact'],
        'responders__user': ['exact', 'isnull']
    }

    EMAIL_SUBJECT = 'A new ticket was requested, ID: {}'

    def get_queryset(self):
        queryset = super(TicketsEndpoint, self).get_queryset()

        if self.request.user.is_superuser:
            return queryset

        # If this is anonymous, for some reason DRF evaluates the
        # authentication after the queryset
        if not self.request.user.is_active:
            return queryset.none()

        return Ticket.filter_by_user(self.request.user, queryset)

    def filter_queryset(self, queryset):
        """Patch filtering method to use the search implementation."""
        filters = self.extract_filter_params(self.request)
        filtered = super(TicketsEndpoint, self).filter_queryset(queryset)

{'fraction_non_alphanumeric': 0.09985185185185186, 'fraction_numerical': 0.0017777777777777779, 'mean_word_length': 3.289707750952986, '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': '319437', 'n_tokens_mistral': 968, 'n_tokens_neox': 941, 'n_words': 247}