Skip to content

Commit

Permalink
move configto cur2
Browse files Browse the repository at this point in the history
  • Loading branch information
iakov-aws committed Nov 21, 2024
1 parent fcccff6 commit 18bfd58
Showing 1 changed file with 62 additions and 46 deletions.
108 changes: 62 additions & 46 deletions dashboards/amazon-connect/amazon-connect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16748,68 +16748,84 @@ crawlers: {}
views:
resource_connect_contact_summary_view:
dependsOn:
cur: true
cur2:
- product_region_code
- product_location
- product['product_usagetype']
- product['country']
data: |-
CREATE OR REPLACE VIEW ${athena_database_name}.resource_connect_contact_summary_view AS
SELECT
"date_trunc"('day', "line_item_usage_start_date") "usage_date"
, product_region region_code
date_trunc('day', line_item_usage_start_date) usage_date
, product_region_code region_code
, product_location region_name
, line_item_resource_id resource_id
, split_part(line_item_resource_id, '/', 4) contact_id
, split_part(line_item_resource_id, '/', 2) connect_instance_id
, COUNT((CASE WHEN (product_line_type = 'Inbound Call') THEN 1 END)) c_inbound_leg
, COUNT((CASE WHEN (product_line_type = 'Outbound Call') THEN 1 END)) c_outbound_leg
, COUNT((CASE WHEN ((product_line_type = '') OR (product_line_type IS NULL)) THEN 1 END)) c_internal_leg
, COUNT((CASE WHEN ((product_country <> '') AND (product_country IS NOT NULL)) THEN product_country END)) c_country
, MAX((CASE WHEN (product_line_type = 'Inbound Call') THEN product_country END)) in_country
, MAX((CASE WHEN (product_line_type = 'Outbound Call') THEN product_country END)) out_country
, ARRAY_JOIN(ARRAY_AGG((CASE WHEN ((product_country <> '') AND (product_country IS NOT NULL)) THEN product_country END)), ',') country_list
, COUNT((CASE WHEN (product['product_usagetype'] = 'Inbound Call') THEN 1 END)) c_inbound_leg
, COUNT((CASE WHEN (product['product_usagetype'] = 'Outbound Call') THEN 1 END)) c_outbound_leg
, COUNT((CASE WHEN ((product['product_usagetype'] = '') OR (product['product_usagetype'] IS NULL)) THEN 1 END)) c_internal_leg
, COUNT((CASE WHEN ((product['country'] <> '') AND (product['country'] IS NOT NULL)) THEN product['country'] END)) c_country
, MAX((CASE WHEN (product['product_usagetype'] = 'Inbound Call') THEN product['country'] END)) in_country
, MAX((CASE WHEN (product['product_usagetype'] = 'Outbound Call') THEN product['country'] END)) out_country
, ARRAY_JOIN(ARRAY_AGG((CASE WHEN ((product['country'] <> '') AND (product['country'] IS NOT NULL)) THEN product['country'] END)), ',') country_list
, SUM(line_item_unblended_cost) cost
, MAX(line_item_usage_amount) max_duration
, MIN("date_trunc"('hour', "line_item_usage_start_date")) contact_start_date_time
, MAX("date_trunc"('hour', "line_item_usage_end_date")) contact_end_date_time
, MIN(date_trunc('hour', line_item_usage_start_date)) contact_start_date_time
, MAX(date_trunc('hour', line_item_usage_end_date)) contact_end_date_time
FROM
${cur_table_name}
WHERE ((line_item_resource_id LIKE '%/contact/%') AND (line_item_usage_type LIKE '%-mins') AND (NOT (line_item_usage_type LIKE '%agent-screen-recording-mins')) AND ((((current_date - INTERVAL '30' DAY) <= line_item_usage_start_date) AND (line_item_resource_id <> '')) AND (line_item_product_code IN ('AmazonConnect', 'ContactCenterTelecomm', 'ContactLensAmazonConnect', 'AmazonConnectCases', 'AmazonConnectVoiceID', 'CustomerProfiles'))))
"${cur2_database}"."${cur2_table_name}"
WHERE ((line_item_resource_id LIKE '%/contact/%') AND (line_item_usage_type LIKE '%-mins') AND (NOT (line_item_usage_type LIKE '%agent-screen-recording-mins')) AND ((((current_date - INTERVAL '30' DAY) <= line_item_usage_start_date) AND (line_item_resource_id <> '')) AND (line_item_product_code IN ('AmazonConnect', 'ContactCenterTelecomm', 'ContactLensAmazonConnect', 'AmazonConnectCases', 'AmazonConnectVoiceID', 'CustomerProfiles'))))
GROUP BY 1, 2, 3, 4
resource_connect_view:
dependsOn:
cur: true
cur2:
- product['product_name']
- product['calling_type']
- product['channel']
- product['country']
- product['line_type']
- product['region']
- product['location']
- product['group']
- product['product_family']
- product['servicecode']
- product['servicename']
- pricing_unit
data: |-
CREATE OR REPLACE VIEW ${athena_database_name}.resource_connect_view AS
SELECT DISTINCT
"date_trunc"('day', "line_item_usage_start_date") "usage_date"
, "bill_payer_account_id" "payer_account_id"
, "line_item_usage_account_id" "linked_account_id"
, "bill_billing_entity" "billing_entity"
, "product_product_name" "product_name"
, "product_calling_type" "calling_type"
, "product_channel" "channel"
, "product_country" "country"
, "product_line_type" "line_type"
, "line_item_usage_start_date" "usage_start_date_time"
, "line_item_usage_end_date" "usage_end_date_time"
, "line_item_resource_id" "resource_id"
"date_trunc"('day', line_item_usage_start_date) "usage_date"
, bill_payer_account_id "payer_account_id"
, line_item_usage_account_id "linked_account_id"
, bill_billing_entity "billing_entity"
, product['product_name'] "product_name"
, product['calling_type'] "calling_type"
, product['channel'] "channel"
, product['country'] "country"
, product['line_type'] "line_type"
, line_item_usage_start_date "usage_start_date_time"
, line_item_usage_end_date "usage_end_date_time"
, line_item_resource_id "resource_id"
, split_part(line_item_resource_id, '/', 4) contact_id
, "line_item_product_code" "product_code"
, "line_item_operation" "operation"
, "line_item_line_item_type" "charge_type"
, "line_item_usage_type" "usage_type"
, "line_item_unblended_rate" "rate"
, "pricing_unit" "pricing_unit"
, "product_region" "region"
, "product_location" "location"
, "line_item_line_item_description" "item_description"
, "line_item_legal_entity" "legal_entity"
, "pricing_term" "pricing_term"
, "product_group" "product_group"
, "product_product_family" "product_family"
, "product_servicecode" "service"
, "product_servicename" "servicename"
, "sum"("line_item_usage_amount") usage_quantity
, "sum"("line_item_unblended_cost") unblended_cost
, line_item_product_code "product_code"
, line_item_operation "operation"
, line_item_line_item_type "charge_type"
, line_item_usage_type "usage_type"
, line_item_unblended_rate "rate"
, pricing_unit "pricing_unit"
, product['region'] "region"
, product['location'] "location"
, line_item_line_item_description "item_description"
, line_item_legal_entity "legal_entity"
, pricing_term "pricing_term"
, product['group'] "product_group"
, product['product_family'] "product_family"
, product['servicecode'] "service"
, product['servicename'] "servicename"
, "sum"(line_item_usage_amount) usage_quantity
, "sum"(line_item_unblended_cost) unblended_cost
FROM
"${cur_table_name}"
WHERE ((((current_date - INTERVAL '30' DAY) <= line_item_usage_start_date) AND (line_item_resource_id <> '')) AND (line_item_product_code IN ('AmazonConnect', 'ContactCenterTelecomm', 'ContactLensAmazonConnect', 'AmazonConnectCases', 'AmazonConnectVoiceID', 'CustomerProfiles')))
"${cur2_database}"."${cur2_table_name}"
WHERE ((((CURRENT_DATE - INTERVAL '30' DAY) <= line_item_usage_start_date) AND (line_item_resource_id <> '')) AND (line_item_product_code IN ('AmazonConnect', 'ContactCenterTelecomm', 'ContactLensAmazonConnect', 'AmazonConnectCases', 'AmazonConnectVoiceID', 'CustomerProfiles')))
GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28

0 comments on commit 18bfd58

Please sign in to comment.