Class: Kpi

Inherits:
ApplicationRecord show all
Includes:
Models::Auditable
Defined in:
app/models/kpi.rb

Overview

== Schema Information

Table name: kpis
Database name: primary

id :bigint not null, primary key
kpi_code :integer not null
kpi_date :date not null
notes :string
tier1 :integer
tier2 :integer
tier3 :integer
created_at :datetime not null
updated_at :datetime not null
creator_id :integer
updater_id :integer

Indexes

index_kpis_on_creator_id (creator_id)
index_kpis_on_kpi_code (kpi_code)
index_kpis_on_kpi_date (kpi_date)
index_kpis_on_tier1 (tier1)
index_kpis_on_tier2 (tier2)
index_kpis_on_tier3 (tier3)
index_kpis_on_updater_id (updater_id)

Constant Summary

Constants included from Models::Auditable

Models::Auditable::ALWAYS_IGNORED

Class Method Summary collapse

Methods included from Models::Auditable

#all_skipped_columns, #audit_reference_data, #creator, #should_not_save_version, #stamp_record, #updater

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::EventPublishable

#publish_event

Class Method Details

.sortedActiveRecord::Relation<Kpi>

A relation of Kpis that are sorted. Active Record Scope

Returns:

  • (ActiveRecord::Relation<Kpi>)

See Also:



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

scope :sorted, -> { order(:kpi_date,:kpi_code) }

.with_code_nameActiveRecord::Relation<Kpi>

A relation of Kpis that are with code name. Active Record Scope

Returns:

  • (ActiveRecord::Relation<Kpi>)

See Also:



32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/models/kpi.rb', line 32

scope :with_code_name, -> { select("kpis.*,(case when kpi_code = 1 then 'Time on Available'
when kpi_code = 2 then 'Inbound Calls'
when kpi_code = 3 then 'Oubound Calls'
when kpi_code = 4 then 'Missed Calls'
when kpi_code = 5 then 'Talk Time'
when kpi_code = 6 then 'Live Chat'
when kpi_code = 7 then 'Activities CMP'
when kpi_code = 8 then 'Accounts CRTD'
when kpi_code = 9 then 'Opprts CRTD'
when kpi_code = 10 then 'Orders CRTD'
when kpi_code = 11 then 'SMS Sent'
when kpi_code = 12 then 'Supt Cases CRTD' else '' end) as kpi_name") }