<commit_before>from django.contrib.auth.models import AnonymousUser

from core.models import Group, Size, Provider
from core.query import only_current, only_current_provider

from api.v2.serializers.details import SizeSerializer
from api.v2.views.base import AuthReadOnlyViewSet
from api.v2.views.mixins import MultipleFieldLookup


class SizeViewSet(MultipleFieldLookup, AuthReadOnlyViewSet):
    """
    API endpoint that allows instance actions to be viewed or edited.
    """
    lookup_fields = ("id", "uuid")
    queryset = Size.objects.all()
    serializer_class = SizeSerializer
    filter_fields = ('provider__id',)

    def get_queryset(self):
        """
        Filter projects by current user
        """
        request_user = self.request.user
        # Switch based on user's ClassType
        if isinstance(request_user, AnonymousUser):
            provider_ids = Provider.objects.filter(only_current(), active=True).values_list('id',flat=True)
        else:<commit_msg>ATMO-1208 -- Sizes should be sorted by the API<commit_after>from django.contrib.auth.models import AnonymousUser

from core.models import Group, Size, Provider
from core.query import only_current, only_current_provider

from api.v2.serializers.details import SizeSerializer
from api.v2.views.base import AuthReadOnlyViewSet
from api.v2.views.mixins import MultipleFieldLookup


class SizeViewSet(MultipleFieldLookup, AuthReadOnlyViewSet):
    """
    API endpoint that allows instance actions to be viewed or edited.
    """
    lookup_fields = ("id", "uuid")
    queryset = Size.objects.all()
    serializer_class = SizeSerializer
    ordering = ("cpu", "mem", "disk", "root", "name")
    filter_fields = ('provider__id',)

    def get_queryset(self):
        """
        Filter projects by current user
        """
        request_user = self.request.user
        # Switch based on user's ClassType
        if isinstance(request_user, AnonymousUser):
            provider_ids = Provider.objects.filter(only_current(), active=True).values_list('id',flat=True)
        else:
{'fraction_non_alphanumeric': 0.09315866084425037, 'fraction_numerical': 0.0048520135856380394, 'mean_word_length': 3.6970387243735763, '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': '726631', 'n_tokens_mistral': 573, 'n_tokens_neox': 558, 'n_words': 154}