<commit_before>from bot.models import Launch, Notification, DailyDigestRecord
from rest_framework import serializers


class NotificationSerializer(serializers.HyperlinkedModelSerializer):

    class Meta:
        model = Notification
        fields = (
            'launch', 'url', 'wasNotifiedTwentyFourHour', 'wasNotifiedOneHour', 'wasNotifiedTenMinutes',
            'wasNotifiedDailyDigest', 'last_twitter_post', 'last_net_stamp',
            'last_net_stamp_timestamp'
        )
        extra_kwargs = {
            'id': {'read_only': False},
            'slug': {'validators': []},
        }


class DailyDigestRecordSerializer(serializers.HyperlinkedModelSerializer):

    class Meta:
        model = DailyDigestRecord
        fields = (
            'url', 'timestamp', 'messages', 'count', 'data'
        )


class LaunchSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Launch
        fields = (
            'id', 'name', 'url', 'status', 'netstamp', 'wsstamp', 'westamp', 'location_name', 'rocket_name',
            'mission_name'
        )

    def create(self, validated_data):
        launch = Launch.objects.get_or_create(**validated_data)
        try:
            if Notification.objects.get(launch=launch[0]) is None:
                Notification.objects.get_or_create(launch=launch[0])
        except:
            Notification.objects.get_or_create(launch=launch[0])
        return launch

    def update(self, instance, validated_data):
        instance.id = validated_data.get('id', instance.id)
        instance.name = validated_data.get('name', instance.name)
        instance.status = validated_data.get('status', instance.status)
        instance.netstamp = validated_data.get('netstamp', instance.netstamp)
        instance.wsstamp = validated_data.get('wsstamp', instance.wsstamp)
        instance.westamp = validated_data.get('westamp', instance.westamp)
        instance.location_name = validated_data.get('location_name', instance.location_name)
        instance.rocket_name = validated_data.get('rocket_name', instance.rocket_name)
        instance.mission_name = validated_data.get('mission_name', instance.mission_name)
        instance.save()

        return instance

    def get_object(self):
        return self.model(self.validated_data)

<commit_msg>Add JSON to data.<commit_after>from bot.models import Launch, Notification, DailyDigestRecord
from rest_framework import serializers


class NotificationSerializer(serializers.HyperlinkedModelSerializer):

    class Meta:
        model = Notification
        fields = (
            'launch', 'url', 'wasNotifiedTwentyFourHour', 'wasNotifiedOneHour', 'wasNotifiedTenMinutes',
            'wasNotifiedDailyDigest', 'last_twitter_post', 'last_net_stamp',
            'last_net_stamp_timestamp'
        )
        extra_kwargs = {
            'id': {'read_only': False},
            'slug': {'validators': []},
        }


class DailyDigestRecordSerializer(serializers.HyperlinkedModelSerializer):

    class Meta:
        model = DailyDigestRecord
        fields = '__all__'


class LaunchSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Launch
        fields = (
            'id', 'name', 'url', 'status', 'netstamp', 'wsstamp', 'westamp', 'location_name', 'rocket_name',
            'mission_name'
        )

    def create(self, validated_data):
        launch = Launch.objects.get_or_create(**validated_data)
        try:
            if Notification.objects.get(launch=launch[0]) is None:
                Notification.objects.get_or_create(launch=launch[0])
        except:
            Notification.objects.get_or_create(launch=launch[0])
        return launch

    def update(self, instance, validated_data):
        instance.id = validated_data.get('id', instance.id)
        instance.name = validated_data.get('name', instance.name)
        instance.status = validated_data.get('status', instance.status)
        instance.netstamp = validated_data.get('netstamp', instance.netstamp)
        instance.wsstamp = validated_data.get('wsstamp', instance.wsstamp)
        instance.westamp = validated_data.get('westamp', instance.westamp)
        instance.location_name = validated_data.get('location_name', instance.location_name)
        instance.rocket_name = validated_data.get('rocket_name', instance.rocket_name)
        instance.mission_name = validated_data.get('mission_name', instance.mission_name)
        instance.save()

        return instance

    def get_object(self):
        return self.model(self.validated_data)


{'fraction_non_alphanumeric': 0.10876198779424585, 'fraction_numerical': 0.0013077593722755014, 'mean_word_length': 3.0936663693131132, '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': '1952485', 'n_tokens_mistral': 1356, 'n_tokens_neox': 1266, 'n_words': 227}