<commit_before>from rest_framework import serializers
from .models import User, Topic, Feed, Post, UserSettings, PostsRead

class UserSerializer(serializers.ModelSerializer):
    topics = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
    settings = serializers.PrimaryKeyRelatedField(many=False, read_only=True)
    class Meta:
        model = User
        fields = ('id', 'username', 'first_name', 'last_name', 'topics', 'readPosts' )

class UserSettingsSerializer(serializers.ModelSerializer):
    class Meta:
        model = UserSettings
        fields = ('readtime',)

class TopicSerializer(serializers.ModelSerializer):
    #feeds = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
    class Meta:
        model = Topic
        #fields = ('id', 'name', 'user', 'feeds', )

class FeedSerializer(serializers.ModelSerializer):
    posts = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
    class Meta:
        model = Feed
        fields = ("id", "author", "category", "contributor", "description", "docURL",
            "editorAddr", "generator", "guid", "language", "logo", "rights",
            "subtitle", "title", "webmaster", "URL", "ttl", "skipDays",
            "skipHours", "pubDate", "updated", "posts", )

class PostSerializer(serializers.ModelSerializer):
    class Meta:
    Length = serializers.SerializerMethodField('get_post_length')
        model = Post
        # fields = ("feedURL", "author", "category", "rights", "title",
        #     "subtitle", "content", "generator", "guid", "url", "contributor",
        #     "pubDate", "updated", "ackDate", )
    def get_post_length(self, obj):
        words = obj.content.split()
        return len(words)

class PostsReadSerializer(serializers.ModelSerializer):
    Length = serializers.SerializerMethodField('get_post_length')
    # posts = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
    class Meta:
        model = PostsRead
        #fields = ('id', 'user', 'feed', 'posts' )<commit_msg>post length unjanked<commit_after>from rest_framework import serializers
from .models import User, Topic, Feed, Post, UserSettings, PostsRead

class UserSerializer(serializers.ModelSerializer):
    topics = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
    settings = serializers.PrimaryKeyRelatedField(many=False, read_only=True)
    class Meta:
        model = User
        fields = ('id', 'username', 'first_name', 'last_name', 'topics', 'readPosts' )

class UserSettingsSerializer(serializers.ModelSerializer):
    class Meta:
        model = UserSettings
        fields = ('readtime',)

class TopicSerializer(serializers.ModelSerializer):
    #feeds = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
    class Meta:
        model = Topic
        #fields = ('id', 'name', 'user', 'feeds', )

class FeedSerializer(serializers.ModelSerializer):
    posts = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
    class Meta:
        model = Feed
        fields = ("id", "author", "category", "contributor", "description", "docURL",
            "editorAddr", "generator", "guid", "language", "logo", "rights",
            "subtitle", "title", "webmaster", "URL", "ttl", "skipDays",
            "skipHours", "pubDate", "updated", "posts", )

class PostSerializer(serializers.ModelSerializer):

    Length = serializers.SerializerMethodField('get_post_length')
    class Meta:
        model = Post
        # fields = ("feedURL", "author", "category", "rights", "title",
        #     "subtitle", "content", "generator", "guid", "url", "contributor",
        #     "pubDate", "updated", "ackDate", )
    def get_post_length(self, obj):
        words = obj.content.split()
        return len(words)

class PostsReadSerializer(serializers.ModelSerializer):
    Length = serializers.SerializerMethodField('get_post_length')
    # posts = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
    class Meta:
        model = PostsRead
        #fields = ('id', 'user', 'feed', 'posts' )
{'fraction_non_alphanumeric': 0.13791398912506178, 'fraction_numerical': 0.0, 'mean_word_length': 3.9114077669902914, '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': '3492889', 'n_tokens_mistral': 1184, 'n_tokens_neox': 1152, 'n_words': 266}