<commit_before>from rest_framework import serializers
from feed_filter.models import FacebookPage, Filter, Post, FilteredPost
from django.contrib.auth.models import User


class FacebookPageSerializer(serializers.ModelSerializer):
    class Meta:
        model = FacebookPage

class FilterSerializer(serializers.ModelSerializer):
    pages = FacebookPageSerializer(many=True)

    class Meta:
        model = Filter

    def create(self, validated_data):
        # TODO - Add create and update methods to handle page creation
        pages_data = validated_data.pop("pages")
        feed_filter = Filter.objects.create

class FilteredPostSerializer(serializers.ModelSerializer):
    class Meta:
        model = FilteredPost<commit_msg>the serializers still arent working. Gonna have to fix that and probably add a test<commit_after>from rest_framework import serializers
from feed_filter.models import FacebookPage, Filter, Post, FilteredPost
from django.contrib.auth.models import User


class FacebookPageSerializer(serializers.ModelSerializer):
    class Meta:
        model = FacebookPage

class FilterSerializer(serializers.ModelSerializer):
    pages = FacebookPageSerializer(many=True)

    class Meta:
        model = Filter

    def create(self, validated_data):
        pages_data = validated_data.pop("pages")
        pages = []
        for page_data in pages_data:
            # This may cause a problem were some group names are overriden. We
            # should find a smarter solution
            # TODO: Make this work!
            page = FacebookPage.objects.update_or_create(
                defaults={"name": page_data["name"]},
                id=page_data["id"]
            )[0]
            pages.append(page)
        return Filter.objects.create(pages=pages, **validated_data)


class FilteredPostSerializer(serializers.ModelSerializer):
    class Meta:
        model = FilteredPost
{'fraction_non_alphanumeric': 0.07034120734908136, 'fraction_numerical': 0.0005249343832020997, 'mean_word_length': 3.2639821029082774, 'pattern_counts': {'":': 1, '<': 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': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4522657', 'n_tokens_mistral': 487, 'n_tokens_neox': 471, 'n_words': 142}