<commit_before>from django.contrib.auth import get_user_model
from django_filters import rest_framework as filters

from main import models


class UserFilterSet(filters.FilterSet):
    project__id = filters.NumberFilter(name='project', method='filter_project_id_custodians')
    project__name = filters.CharFilter(name='project', method='filter_project_name_custodians')
    project__code = filters.CharFilter(name='project', method='filter_project_code_custodians')

    @staticmethod
    def filter_project_id_custodians(queryset, name, project_ids):
        if not isinstance(project_ids, list):
            project_ids = [project_ids]
        return queryset.filter(project__in=project_ids)

    @staticmethod
    def filter_project_name_custodians(queryset, name, project_name):
        project_ids = list(models.Project.objects.filter(name=project_name).values_list('id', flat=True))
        return UserFilterSet.filter_project_id_custodians(queryset, name, project_ids)

    @staticmethod
    def filter_project_code_custodians(queryset, name, project_code):
        project_ids = list(models.Project.objects.filter(code=project_code).values_list('id', flat=True))
        return UserFilterSet.filter_project_id_custodians(queryset, name, project_ids)

    class Meta:
        model = get_user_model()
        fields = {
            'id': ['exact', 'in'],
            'username': ['exact', 'icontains'],
            'first_name': ['exact', 'icontains'],<commit_msg>Change NumberFilter to CharFilter<commit_after>from django.contrib.auth import get_user_model
from django_filters import rest_framework as filters

from main import models


class UserFilterSet(filters.FilterSet):
    project__id = filters.CharFilter(name='project', method='filter_project_id_custodians')
    project__name = filters.CharFilter(name='project', method='filter_project_name_custodians')
    project__code = filters.CharFilter(name='project', method='filter_project_code_custodians')

    @staticmethod
    def filter_project_id_custodians(queryset, name, project_ids):
        if not isinstance(project_ids, list):
            project_ids = [project_ids]
        return queryset.filter(project__in=project_ids)

    @staticmethod
    def filter_project_name_custodians(queryset, name, project_name):
        project_ids = list(models.Project.objects.filter(name=project_name).values_list('id', flat=True))
        return UserFilterSet.filter_project_id_custodians(queryset, name, project_ids)

    @staticmethod
    def filter_project_code_custodians(queryset, name, project_code):
        project_ids = list(models.Project.objects.filter(code=project_code).values_list('id', flat=True))
        return UserFilterSet.filter_project_id_custodians(queryset, name, project_ids)

    class Meta:
        model = get_user_model()
        fields = {
            'id': ['exact', 'in'],
            'username': ['exact', 'icontains'],
            'first_name': ['exact', 'icontains'],
{'fraction_non_alphanumeric': 0.10256410256410256, 'fraction_numerical': 0.0, 'mean_word_length': 4.658396946564886, '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': '5372102', 'n_tokens_mistral': 888, 'n_tokens_neox': 871, 'n_words': 154}