<commit_before>from rest_framework import serializers
from rest_framework.reverse import reverse

from chat.models import Member
from chat.models import Message
from chat.models import ChatRoom


class MemberSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Member


class ChatRoomSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = ChatRoom


class MessageSerializer(serializers.HyperlinkedModelSerializer):
    url = serializers.SerializerMethodField('get_url')
<commit_msg>Add a link to the messages of a ChatRoom in its representation<commit_after>from rest_framework import serializers
from rest_framework.reverse import reverse

from chat.models import Member
from chat.models import Message
from chat.models import ChatRoom


class MemberSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Member


class ChatRoomSerializer(serializers.HyperlinkedModelSerializer):
    messages = serializers.SerializerMethodField('get_messages_url')

    def get_messages_url(self, chat_room):
        return reverse(
            'message-list',
            kwargs={'chat_room': chat_room.pk},
            request=self.context.get('request', None)
        )

    class Meta:
        model = ChatRoom


class MessageSerializer(serializers.HyperlinkedModelSerializer):
    url = serializers.SerializerMethodField('get_url')

{'fraction_non_alphanumeric': 0.06378454996456413, 'fraction_numerical': 0.0, 'mean_word_length': 4.494163424124514, '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': '1744896', 'n_tokens_mistral': 356, 'n_tokens_neox': 342, 'n_words': 95}