<commit_before># -*- coding: utf-8 -*-
from rest_framework import viewsets
from rest_framework.response import Response

from server.models import Guide
from server.serializers.client import GuideSerializer, GuideListSerializer
from server.filters.client import GuideFilter


class GuideViewSet(viewsets.ReadOnlyModelViewSet):

    queryset = Guide.objects.filter(seasons__current=True, deprecated=False)
    search_fields = ('user__last_name', 'user__first_name')
    filter_class = GuideFilter

    def list(self, request, *args, **kwargs):
        response = super(GuideViewSet, self).list(request, *args, **kwargs)
        latest = Guide.objects.latest()
        response['Cache-Control'] = "public"
        response['ETag'] = latest.get_etag()
        response['Last-Modified'] = latest.updated
        return response

    def retrieve(self, request, *args, **kwargs):
        instance = self.get_object()
        response = super(GuideViewSet, self).retrieve(request, *args, **kwargs)
        response['Cache-Control'] = "public"
        response['ETag'] = instance.get_etag()
        response['Last-Modified'] = instance.updated
        return response

    def get_serializer_class(self):
        if self.action == 'list':
            return GuideListSerializer
        return GuideSerializer

    class Meta:
        model = Guide
<commit_msg>fixing Etag format<commit_after># -*- coding: utf-8 -*-
from rest_framework import viewsets
from rest_framework.response import Response

from server.models import Guide
from server.serializers.client import GuideSerializer, GuideListSerializer
from server.filters.client import GuideFilter


class GuideViewSet(viewsets.ReadOnlyModelViewSet):

    queryset = Guide.objects.filter(seasons__current=True, deprecated=False)
    search_fields = ('user__last_name', 'user__first_name')
    filter_class = GuideFilter

    def list(self, request, *args, **kwargs):
        response = super(GuideViewSet, self).list(request, *args, **kwargs)
        latest = Guide.objects.latest()
        response['Cache-Control'] = "public"
        response['ETag'] = '"{}"'.format(latest.get_etag())
        response['Last-Modified'] = latest.updated
        return response

    def retrieve(self, request, *args, **kwargs):
        instance = self.get_object()
        response = super(GuideViewSet, self).retrieve(request, *args, **kwargs)
        response['Cache-Control'] = "public"
        response['ETag'] = '"{}"'.format(instance.get_etag())
        response['Last-Modified'] = instance.updated
        return response

    def get_serializer_class(self):
        if self.action == 'list':
            return GuideListSerializer
        return GuideSerializer

    class Meta:
        model = Guide

{'fraction_non_alphanumeric': 0.11455673112002919, 'fraction_numerical': 0.0007296607077708865, 'mean_word_length': 3.5322314049586776, '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': '3088456', 'n_tokens_mistral': 747, 'n_tokens_neox': 730, 'n_words': 176}