New table for calls history in report format
This commit is contained in:
parent
5f9909a7d6
commit
48e5ae7399
72
definitions/staging/stg_calls_history_report.sqlx
Normal file
72
definitions/staging/stg_calls_history_report.sqlx
Normal file
@ -0,0 +1,72 @@
|
||||
config {
|
||||
type: "incremental",
|
||||
uniqueKey: ["SESSION_ID", "TIMESTAMP", "DNIS"],
|
||||
schema: "pphe_five9_stg",
|
||||
assertions: {
|
||||
uniqueKey: ["SESSION_ID", "TIMESTAMP", "DNIS"],
|
||||
nonNull: ["SESSION_ID", "TIMESTAMP", "DNIS", "AGENT_GROUP_ID", "DISPOSITION_ID", "DISPOSITION_GROUP_ID",
|
||||
"DISPOSITION_GROUP", "CAMPAIGN_ID", "CAMPAIGN_GROUP_ID",
|
||||
"CAMPAIGN_GROUP", "SKILL_ID"]
|
||||
},
|
||||
tags: ["calls_report"],
|
||||
description: "Main calls data for history report"
|
||||
}
|
||||
|
||||
select sc.SESSION_ID,
|
||||
sc.DNIS,
|
||||
sc.TIMESTAMP,
|
||||
date(sc.TIMESTAMP) DATE,
|
||||
EXTRACT(HOUR FROM sc.TIMESTAMP) HOUR,
|
||||
EXTRACT(MONTH FROM sc.TIMESTAMP) MONTH,
|
||||
EXTRACT(YEAR FROM sc.TIMESTAMP) YEAR,
|
||||
sc.DAY_OF_WEEK,
|
||||
sc.CALL_ID,
|
||||
sc.ROUTING_HOTEL_NAME,
|
||||
sc.AGENT_ID,
|
||||
sc.AGENT_NAME,
|
||||
a.LANGUAGES,
|
||||
a.CODE LANGUAUGE_ID,
|
||||
a.AGENT_GROUP_ID,
|
||||
sc.AGENT_GROUP,
|
||||
d.DISPOSITION_ID,
|
||||
sc.DISPOSITION,
|
||||
d.DISPOSITION_GROUP_ID,
|
||||
d.DISPOSITION_GROUP,
|
||||
c.CAMPAIGN_ID,
|
||||
sc.CAMPAIGN,
|
||||
c.CAMPAIGN_GROUP_ID,
|
||||
c.CAMPAIGN_GROUP,
|
||||
sc.SKILL,
|
||||
s.SKILL_ID,
|
||||
sc.CALL_TIME,
|
||||
sc.CALL_TIME_FORMATTED,
|
||||
sc.RING_TIME,
|
||||
sc.RING_TIME_FORMATTED,
|
||||
sc.TALK_TIME,
|
||||
sc.TALK_TIME_FORMATTED,
|
||||
sc.SPEED_OF_ANSWER,
|
||||
sc.SPEED_OF_ANSWER_FORMATTED,
|
||||
sc.AFTER_CALL_WORK_TIME,
|
||||
sc.AFTER_CALL_WORK_TIME_FORMATTED,
|
||||
sc.HOLD_TIME,
|
||||
sc.HOLD_TIME_FORMATTED,
|
||||
sc.TALK_TIME_LESS_HOLD_AND_PARK,
|
||||
sc.TALK_TIME_LESS_HOLD_AND_PARK_FORMATTED,
|
||||
sc.TRANSFERS,
|
||||
sc.ABANDONED,
|
||||
sc.CALLS,
|
||||
sc.ANI,
|
||||
c.CAMPAIGN_TYPE_ID,
|
||||
sc.CAMPAIGN_TYPE,
|
||||
"PHONE" MEDIA_TYPE_ID
|
||||
from ${ref("stg_calls")} sc
|
||||
left join ${ref("stg_AGENT")} a
|
||||
on sc.AGENT_ID = a.AGENT_ID
|
||||
left join ${ref("stg_DISPOSITION")} d
|
||||
on sc.DISPOSITION = d.DISPOSITION
|
||||
left join ${ref("stg_CAMPAIGN")} c
|
||||
on sc.CAMPAIGN = c.CAMPAIGN
|
||||
left join ${ref("stg_MAPPING_SKILL")} s
|
||||
on sc.SKILL = s.SKILL
|
||||
${ when(incremental(), `where date(sc.TIMESTAMP) >= DATE_SUB(CURRENT_DATE(), INTERVAL 6 DAY)
|
||||
and date(sc.TIMESTAMP) < CURRENT_DATE()`) }
|
||||
Loading…
Reference in New Issue
Block a user