Create report table for agent status
This commit is contained in:
parent
5b5e923696
commit
b74ec1d161
56
definitions/staging/stg_agent_status_report.sqlx
Normal file
56
definitions/staging/stg_agent_status_report.sqlx
Normal file
@ -0,0 +1,56 @@
|
||||
config {
|
||||
type: "table",
|
||||
uniqueKey: ["AGENT_ID", "TIMESTAMP", "STATE"],
|
||||
schema: "pphe_five9_stg",
|
||||
assertions: {
|
||||
uniqueKey: ["AGENT_ID", "TIMESTAMP", "STATE"],
|
||||
nonNull: ["AGENT_ID", "TIMESTAMP", "STATE"],
|
||||
rowConditions: [
|
||||
'AGENT_NAME <> "NOT_MAPPED"',
|
||||
'STATE_GROUP <> "NOT_MAPPED"'
|
||||
]
|
||||
},
|
||||
tags: ["agent_status_report"],
|
||||
description: "Main agent status data for report"
|
||||
}
|
||||
|
||||
--Extraction and transformation of fields that are used in Board load further. Contains last 7 days
|
||||
select ags.AGENT_ID,
|
||||
COALESCE(a.AGENT_NAME, 'NOT_MAPPED') as AGENT_NAME,
|
||||
COALESCE(a.AGENT_GROUP, 'NOT_MAPPED') as AGENT_GROUP,
|
||||
COALESCE(a.AGENT_GROUP_ID, 'NOT_MAPPED') as AGENT_GROUP_ID,
|
||||
COALESCE(a.LANGUAGES, 'NOT_MAPPED') as LANGUAGES,
|
||||
COALESCE(a.CODE, 'NOT_MAPPED') as LANG_CODE,
|
||||
ags.AGENT_STATE_TIME,
|
||||
ags.AGENT_START_DATE,
|
||||
ags.REASON_CODE,
|
||||
ags.TIMESTAMP,
|
||||
ags.AGENT_STATES,
|
||||
ags.MEDIA_AVAILABILITY,
|
||||
ags.UNAVAILABLE_FOR_CALLS,
|
||||
ags.AVAILABLE_FOR_ALL,
|
||||
ags.UNAVAILABLE_FOR_VM,
|
||||
ags.AVAILABLE_FOR_CALLS,
|
||||
ags.SKILL_AVAILABILITY,
|
||||
ags.AVAILABLE_FOR_VM,
|
||||
ags.STATE,
|
||||
COALESCE(mas.STATE_GROUP, 'NOT_MAPPED') as STATE_GROUP,
|
||||
ags.UNPAID_TIME,
|
||||
regexp_replace(
|
||||
cast(time(timestamp_seconds(cast(ags.UNPAID_TIME as int))) as string),
|
||||
r'^\d\d',
|
||||
cast(extract(hour from time(timestamp_seconds(cast(ags.UNPAID_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(ags.UNPAID_TIME as int)))) as string)
|
||||
) as UNPAID_TIME_FORMATTED,
|
||||
ags.PAID_TIME,
|
||||
regexp_replace(
|
||||
cast(time(timestamp_seconds(cast(ags.PAID_TIME as int))) as string),
|
||||
r'^\d\d',
|
||||
cast(extract(hour from time(timestamp_seconds(cast(ags.PAID_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(ags.PAID_TIME as int)))) as string)
|
||||
) as PAID_TIME_FORMATTED,
|
||||
from ${ref("stg_agent_status")} ags
|
||||
left join ${ref("stg_AGENT")} a
|
||||
on ags.AGENT_ID = a.AGENT_ID
|
||||
left join ${ref("MAPPING_AGENT_STATE")} mas
|
||||
on ags.STATE = mas.STATE
|
||||
where date(ags.TIMESTAMP) >= DATE_SUB(CURRENT_DATE(), INTERVAL 7 DAY)
|
||||
and date(ags.TIMESTAMP) < CURRENT_DATE()
|
||||
Loading…
Reference in New Issue
Block a user