<commit_before>from rest_framework.renderers import JSONRenderer
from solr.activity.serializers import (
    ActivitySectorSerializer, RecipientCountrySerializer, ActivityRecipientRegionSerializer
)
from solr.indexing import BaseIndexing
from solr.utils import (
    add_reporting_org, bool_string, date_string, decimal_string,
    get_child_attr, get_narrative_lang_list
)
from solr.activity.references import (
    RecipientCountryReference, RecipientRegionReference
)


class TransactionIndexing(BaseIndexing):

    def transaction(self):
        transaction = self.record

        self.add_field('id', transaction.id)
        self.add_field('iati_identifier', transaction.activity.iati_identifier)
        if get_child_attr(transaction, 'activity.title'):
            self.indexing['title_lang'], self.indexing['title_narrative'] = \
                get_narrative_lang_list(transaction.activity.title)

        self.add_field('activity_description_type', [])
        self.add_field('activity_description_narrative', [])
        for description in transaction.activity.description_set.all():
            self.add_value_list(
                'activity_description_type',
                description.type_id
            )
            for narrative in description.narratives.all():
                self.add_value_list(
                    'activity_description_narrative',
                    narrative.content
                )

        self.add_field('activity_date_type', [])
        self.add_field('activity_date_iso_date', [])
<commit_msg>fix: flake8 error<commit_after>from solr.indexing import BaseIndexing
from solr.utils import (
    add_reporting_org, bool_string, date_string, decimal_string,
    get_child_attr, get_narrative_lang_list
)


class TransactionIndexing(BaseIndexing):

    def transaction(self):
        transaction = self.record

        self.add_field('id', transaction.id)
        self.add_field('iati_identifier', transaction.activity.iati_identifier)
        if get_child_attr(transaction, 'activity.title'):
            self.indexing['title_lang'], self.indexing['title_narrative'] = \
                get_narrative_lang_list(transaction.activity.title)

        self.add_field('activity_description_type', [])
        self.add_field('activity_description_narrative', [])
        for description in transaction.activity.description_set.all():
            self.add_value_list(
                'activity_description_type',
                description.type_id
            )
            for narrative in description.narratives.all():
                self.add_value_list(
                    'activity_description_narrative',
                    narrative.content
                )

        self.add_field('activity_date_type', [])
        self.add_field('activity_date_iso_date', [])

{'fraction_non_alphanumeric': 0.08715759516186411, 'fraction_numerical': 0.0003557452863749555, 'mean_word_length': 2.900138696255201, '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': '907123', 'n_tokens_mistral': 779, 'n_tokens_neox': 754, 'n_words': 111}