<commit_before>from ovp_core import validators
from ovp_core.models import Availability
from rest_framework import serializers


class AvailabilitySerializer(serializers.ModelSerializer):
  def validate(self, data):
    weekday, period = data.pop('weekday', 0), data.pop('period', 0)
    return {  'period_index': Availability.compose_period_index_for(weekday, period)  }

  class Meta:
    fields = ['weekday', 'period']
    model = Availability<commit_msg>fix AvailabilitySerializer<commit_after>from ovp_core import validators
from ovp_core.models import Availability
from rest_framework import serializers


class AvailabilitySerializer(serializers.ModelSerializer):
  def to_representation(self, instance):
    return { 'weekday': instance.weekday, 'period': instance.period }

  def validate(self, data):
    if not 'period_index' in data:
      data['period_index'] = Availability.compose_period_index_for(data.get('weekday', 0), data.get('period', 0))
    return super().validate(data)

  class Meta:
    fields = ['weekday', 'period']
    model = Availability

{'fraction_non_alphanumeric': 0.10477081384471469, 'fraction_numerical': 0.0037418147801683817, 'mean_word_length': 5.564417177914111, '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': '7041748', 'n_tokens_mistral': 316, 'n_tokens_neox': 305, 'n_words': 78}