<commit_before>from lily.accounts.models import Account
from lily.contacts.models import Contact
from lily.search.base_mapping import BaseMapping
from lily.tags.models import Tag

from .models import Case


class CaseMapping(BaseMapping):
    @classmethod
    def get_model(cls):
        return Case

    @classmethod
    def get_mapping(cls):
        """
        Returns an Elasticsearch mapping for this MappingType.
        """
        mapping = super(CaseMapping, cls).get_mapping()
        mapping['properties'].update({
            'account': {
                'type': 'object',
                'properties': {
                    'id': {'type': 'integer'},
                    'name': {
                        'type': 'string',
                        'analyzer': 'normal_edge_analyzer',
                    },
                },
            },
            'assigned_to': {
                'type': 'object',
                'properties': {
                    'id': {'type': 'integer'},
                    'full_name': {
                        'type': 'string',
                        'analyzer': 'normal_edge_analyzer',
                    },
                },
            },
            'assigned_to_groups': {
                'type': 'integer',
            },
            'contact': {
                'type': 'object',
                'properties': {
                    'id': {'type': 'integer'},
                    'name': {
                        'type': 'string',
                        'analyzer': 'normal_edge_analyzer',
                    },
                },
            },
            'created': {
                'type': 'date',
            },
            'created_by': {
                'type': 'object',
                'properties': {
                    'id': {'type': 'integer'},
                    'full_name': {
                        'type': 'string',
                        'analyzer': 'normal_edge_analyzer',
                    },
                },
            },
            'description': {
                'type': 'string',
                'index_analyzer': 'normal_edge_analyzer',
            },
            'expires': {
                'type': 'date',
            },
            'is_archived': {
                'type': 'boolean',
            },
            'modified': {
                'type': 'date',
            },
            'priority': {
                'type': 'integer',
            },
            'priority_display': {
                'type': 'string',
                'index_analyzer': 'normal_edge_analyzer',
            },
            'status': {
                'type': 'object',
                'properties': {
                    'id': {'type': 'integer'},
                    'name': {
                        'type': 'string',
                        'analyzer': 'normal_edge_analyzer',
                    },
                },
            },
            'subject': {
                'type': 'string',
                'index_analyzer': 'normal_ngram_analyzer',
            },
            'tags': {
                'type': 'object',
                'properties': {
                    'id': {'type': 'integer'},
                    'name': {
                        'type': 'string',
                        'index_analyzer': 'normal_edge_analyzer',
                    },
                    'object_id': {'type': 'integer'},
                },
            },
            'type': {
                'type': 'object',
                'properties': {
                    'id': {'type': 'integer'},
                    'name': {
                        'type': 'string',
                        'analyzer': 'normal_edge_analyzer',
                    },
                },
            },
        })
        return mapping

    @classmethod
    def get_related_models(cls):
        """
        Maps related models, how to get an instance list from a signal sender.
        """
        return {
            Contact: lambda obj: obj.case_set.all(),
            Account: lambda obj: obj.case_set.all(),
            Tag: lambda obj: [obj.subject],
        }

    @classmethod<commit_msg>LILY-1811: Fix wrong cases showing up in 'Callback' widget<commit_after>from lily.accounts.models import Account
from lily.contacts.models import Contact
from lily.search.base_mapping import BaseMapping
from lily.tags.models import Tag

from .models import Case


class CaseMapping(BaseMapping):
    @classmethod
    def get_model(cls):
        return Case

    @classmethod
    def get_mapping(cls):
        """
        Returns an Elasticsearch mapping for this MappingType.
        """
        mapping = super(CaseMapping, cls).get_mapping()
        mapping['properties'].update({
            'account': {
                'type': 'object',
                'properties': {
                    'id': {'type': 'integer'},
                    'name': {
                        'type': 'string',
                        'analyzer': 'normal_edge_analyzer',
                    },
                },
            },
            'assigned_to': {
                'type': 'object',
                'properties': {
                    'id': {'type': 'integer'},
                    'full_name': {
                        'type': 'string',
                        'analyzer': 'normal_edge_analyzer',
                    },
                },
            },
            'assigned_to_groups': {
                'type': 'integer',
            },
            'contact': {
                'type': 'object',
                'properties': {
                    'id': {'type': 'integer'},
                    'name': {
                        'type': 'string',
                        'analyzer': 'normal_edge_analyzer',
                    },
                },
            },
            'created': {
                'type': 'date',
            },
            'created_by': {
                'type': 'object',
                'properties': {
                    'id': {'type': 'integer'},
                    'full_name': {
                        'type': 'string',
                        'analyzer': 'normal_edge_analyzer',
                    },
                },
            },
            'description': {
                'type': 'string',
                'index_analyzer': 'normal_edge_analyzer',
            },
            'expires': {
                'type': 'date',
            },
            'is_archived': {
                'type': 'boolean',
            },
            'modified': {
                'type': 'date',
            },
            'priority': {
                'type': 'integer',
            },
            'priority_display': {
                'type': 'string',
                'index_analyzer': 'normal_edge_analyzer',
            },
            'status': {
                'type': 'object',
                'properties': {
                    'id': {'type': 'integer'},
                    'name': {
                        'type': 'string',
                        'analyzer': 'normal_edge_analyzer',
                    },
                },
            },
            'subject': {
                'type': 'string',
                'index_analyzer': 'normal_ngram_analyzer',
            },
            'tags': {
                'type': 'object',
                'properties': {
                    'id': {'type': 'integer'},
                    'name': {
                        'type': 'string',
                        'index_analyzer': 'normal_edge_analyzer',
                    },
                    'object_id': {'type': 'integer'},
                },
            },
            'type': {
                'type': 'object',
                'properties': {
                    'id': {'type': 'integer'},
                    'name': {
                        'type': 'string',
                        'index_analyzer': 'normal_edge_analyzer',
                    },
                },
            },
        })
        return mapping

    @classmethod
    def get_related_models(cls):
        """
        Maps related models, how to get an instance list from a signal sender.
        """
        return {
            Contact: lambda obj: obj.case_set.all(),
            Account: lambda obj: obj.case_set.all(),
            Tag: lambda obj: [obj.subject],
        }

    @classmethod
{'fraction_non_alphanumeric': 0.13157579388855603, 'fraction_numerical': 0.0004793289394847214, 'mean_word_length': 0.9454545454545454, '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': '311941', 'n_tokens_mistral': 2079, 'n_tokens_neox': 1941, 'n_words': 393}