Class: CallLogEvent

Inherits:
ApplicationRecord show all
Defined in:
app/models/call_log_event.rb

Overview

== Schema Information

Table name: call_log_events
Database name: primary

id :integer not null, primary key
display :string(500)
ext :integer
leg_type :string(30)
start_time :datetime
call_record_id :integer
cdr_call_id :string

Indexes

idx_call_log_events_unique (cdr_call_id,start_time,leg_type,display) UNIQUE
index_call_log_events_call_record_id (leg_type,call_record_id,start_time)
index_call_log_events_on_call_record_id (call_record_id) UNIQUE
index_call_log_events_on_start_time (start_time)

Foreign Keys

fk_rails_... (call_record_id => call_records.id)

Belongs to collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::EventPublishable

#publish_event

Class Method Details

.populate_missing_call_records(start_time: 15.days.ago) ⇒ Object

Fast method that will look through our call recordings and attach them to the talking leg of a call log events



34
35
36
37
# File 'app/models/call_log_event.rb', line 34

def self.populate_missing_call_records(start_time: 15.days.ago)
  clm = Phone::CallLogEventToRecordMatcher.new
  res = clm.process(start_time: start_time)
end

.talkingActiveRecord::Relation<CallLogEvent>

A relation of CallLogEvents that are talking. Active Record Scope

Returns:

See Also:



30
# File 'app/models/call_log_event.rb', line 30

scope :talking, -> { where(leg_type: 'TALKING') }

.without_call_recordsActiveRecord::Relation<CallLogEvent>

A relation of CallLogEvents that are without call records. Active Record Scope

Returns:

See Also:



31
# File 'app/models/call_log_event.rb', line 31

scope :without_call_records, -> { where(call_record_id: nil) }

Instance Method Details

#call_logCallLog

Returns:

See Also:



27
# File 'app/models/call_log_event.rb', line 27

belongs_to :call_log, foreign_key: :cdr_call_id, primary_key: :cdr_call_id, optional: true

#call_recordCallRecord

Returns:

See Also:



28
# File 'app/models/call_log_event.rb', line 28

belongs_to :call_record, optional: true

#to_sObject



39
40
41
# File 'app/models/call_log_event.rb', line 39

def to_s
  "Call Log Event #{id} : #{display}, cdr_call_id: #{cdr_call_id}"
end