<commit_before>from __future__ import absolute_import, unicode_literals

from django.db import models
from django.conf import settings
from django.core.urlresolvers import reverse
from temba.channels.models import ChannelSession
from temba.utils import on_transaction_commit


class IVRManager(models.Manager):
    def create(self, *args, **kwargs):
        return super(IVRManager, self).create(*args, session_type=IVRCall.IVR, **kwargs)

    def get_queryset(self):
        return super(IVRManager, self).get_queryset().filter(session_type=IVRCall.IVR)


class IVRCall(ChannelSession):

    objects = IVRManager()

    class Meta:
        proxy = True

    @classmethod
    def create_outgoing(cls, channel, contact, contact_urn, user):
        return IVRCall.objects.create(channel=channel, contact=contact, contact_urn=contact_urn,
                                      direction=IVRCall.OUTGOING, org=channel.org,
                                      created_by=user, modified_by=user)

    @classmethod
    def create_incoming(cls, channel, contact, contact_urn, user):
        return IVRCall.objects.create(channel=channel, contact=contact, contact_urn=contact_urn,
                                      direction=IVRCall.INCOMING, org=channel.org, created_by=user,
                                      modified_by=user, external_id=external_id)

    @classmethod
    def hangup_test_call(cls, flow):
        # if we have an active call, hang it up<commit_msg>fix merge<commit_after>from __future__ import absolute_import, unicode_literals

from django.db import models
from django.conf import settings
from django.core.urlresolvers import reverse
from temba.channels.models import ChannelSession
from temba.utils import on_transaction_commit


class IVRManager(models.Manager):
    def create(self, *args, **kwargs):
        return super(IVRManager, self).create(*args, session_type=IVRCall.IVR, **kwargs)

    def get_queryset(self):
        return super(IVRManager, self).get_queryset().filter(session_type=IVRCall.IVR)


class IVRCall(ChannelSession):

    objects = IVRManager()

    class Meta:
        proxy = True

    @classmethod
    def create_outgoing(cls, channel, contact, contact_urn, user):
        return IVRCall.objects.create(channel=channel, contact=contact, contact_urn=contact_urn,
                                      direction=IVRCall.OUTGOING, org=channel.org,
                                      created_by=user, modified_by=user)

    @classmethod
    def create_incoming(cls, channel, contact, contact_urn, user, external_id):
        return IVRCall.objects.create(channel=channel, contact=contact, contact_urn=contact_urn,
                                      direction=IVRCall.INCOMING, org=channel.org, created_by=user,
                                      modified_by=user, external_id=external_id)

    @classmethod
    def hangup_test_call(cls, flow):
        # if we have an active call, hang it up
{'fraction_non_alphanumeric': 0.08245673566338649, 'fraction_numerical': 0.0, 'mean_word_length': 3.0, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2806313', 'n_tokens_mistral': 838, 'n_tokens_neox': 811, 'n_words': 187}