<commit_before># -*- coding: utf-8 -*-
import functools

from django.contrib.postgres.fields import ArrayField
from django.db import models
from osf.models.base import BaseModel, ObjectIDMixin


def _serialize(fields, instance):
    return {
        field: getattr(instance, field)
        for field in fields
    }

serialize_node_license = functools.partial(_serialize, ('_id', 'name', 'text'))

def serialize_node_license_record(node_license_record):
    if node_license_record is None:
        return {}
    ret = serialize_node_license(node_license_record.node_license)
    ret.update(_serialize(('year', 'copyright_holders'), node_license_record))
    return ret<commit_msg>Fix license serialization bug<commit_after># -*- coding: utf-8 -*-
import functools

from django.contrib.postgres.fields import ArrayField
from django.db import models
from osf.models.base import BaseModel, ObjectIDMixin


def _serialize(fields, instance):
    return {
        field: getattr(instance, field if field != 'id' else 'license_id')
        for field in fields
    }

serialize_node_license = functools.partial(_serialize, ('id', 'name', 'text'))

def serialize_node_license_record(node_license_record):
    if node_license_record is None:
        return {}
    ret = serialize_node_license(node_license_record.node_license)
    ret.update(_serialize(('year', 'copyright_holders'), node_license_record))
    return ret
{'fraction_non_alphanumeric': 0.09929078014184398, 'fraction_numerical': 0.0014184397163120568, 'mean_word_length': 4.599206349206349, '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': '2812432', 'n_tokens_mistral': 413, 'n_tokens_neox': 410, 'n_words': 103}