<commit_before>Voice.CompCall = Ember.Mixin.create({

  compare: (x, y) ->
    return 0 if x.get('id') == y.get('id')
    return 1
})


Voice.Call = DS.Model.extend(Ember.Comparable, Voice.CompCall, Voice.Resetable, {

  allCallsBinding: 'Voice.allCalls'
  allUsersBinding: 'Voice.allUsers'

  origin:        null
  bridge:        null

  skill:         DS.attr 'string'
  hungup:        DS.attr 'boolean'
  callTag:       DS.attr 'string'
  mailbox:       DS.attr 'string'
  calledAt:      DS.attr 'date'
  callerId:      DS.attr 'string'
  hungupAt:      DS.attr 'date'
  language:      DS.attr 'string'
  originId:      DS.attr 'string'
  queuedAt:      DS.attr 'date'
  extension:     DS.attr 'string'
  dispatchedAt:  DS.attr 'date'


  init: ->
    @_super()
    @updateMatchesFilter()


  skillName: ( ->
    skill = @get('skill')
    skill.replace(/_/, ' ').capitalize() if skill
  ).property('skill')


  hangup: ->
    callId = @get('id')
    $.post("#{env.apiVersion}/calls/#{callId}", {'_method': 'DELETE'})


  removeAfterHangup: (->
    if @get('hungup') && @isForeignCall()
      Ember.run.later @, @remove, 3000
  ).observes('hungup')


  isForeignCall: ->
    return true unless @get('callTag')
    cc = Voice.get('currentCall')
    !cc || @ != cc && @ != cc.get('origin')
<commit_msg>avoid repeated hungup call removal<commit_after>Voice.CompCall = Ember.Mixin.create({

  compare: (x, y) ->
    return 0 if x.get('id') == y.get('id')
    return 1
})


Voice.Call = DS.Model.extend(Ember.Comparable, Voice.CompCall, Voice.Resetable, {

  allCallsBinding: 'Voice.allCalls'
  allUsersBinding: 'Voice.allUsers'

  removing:      null
  origin:        null
  bridge:        null

  skill:         DS.attr 'string'
  hungup:        DS.attr 'boolean'
  callTag:       DS.attr 'string'
  mailbox:       DS.attr 'string'
  calledAt:      DS.attr 'date'
  callerId:      DS.attr 'string'
  hungupAt:      DS.attr 'date'
  language:      DS.attr 'string'
  originId:      DS.attr 'string'
  queuedAt:      DS.attr 'date'
  extension:     DS.attr 'string'
  dispatchedAt:  DS.attr 'date'


  init: ->
    @_super()
    @updateMatchesFilter()


  skillName: ( ->
    skill = @get('skill')
    skill.replace(/_/, ' ').capitalize() if skill
  ).property('skill')


  hangup: ->
    callId = @get('id')
    $.post("#{env.apiVersion}/calls/#{callId}", {'_method': 'DELETE'})


  removeAfterHangup: (->
    if @get('hungup') && !@get('removing') && @isForeignCall()
      @set 'removing', true
      Ember.run.later @, @remove, 3000
  ).observes('hungup')


  isForeignCall: ->
    return true unless @get('callTag')
    cc = Voice.get('currentCall')
    !cc || @ != cc && @ != cc.get('origin')

{'fraction_non_alphanumeric': 0.17025222551928784, 'fraction_numerical': 0.004451038575667656, 'mean_word_length': 2.639676113360324, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '2756475', 'n_tokens_mistral': 1006, 'n_tokens_neox': 965, 'n_words': 200}