From c3d0b6267d51a1f6962b4b139e29f97ccec13c48 Mon Sep 17 00:00:00 2001 From: Rene Krenn Date: Mon, 5 Feb 2018 11:56:28 +0100 Subject: [PATCH] TT#27463 edr export localized time columns new columns available: EVENT_TIMESTAMP: same as TIMESTAMP (the edr event timestamp), but including formatting (fractional seconds + rounding) exactly like cdr START_TIME/INIT_TIME/END_TIME EVENT_TIMEZONE: the subscriber's inherited timezone TIMESTAMP_LOCALIZED: the event's timestamp with the subscriber's inherited timezone applied. same formatting as EVENT_TIMESTAMP Change-Id: Id63b92d111e1c5bdb36e9f710f1d464e9e7ed44c --- lib/get_cdr_export_fields | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/get_cdr_export_fields b/lib/get_cdr_export_fields index 394227a4..bba46599 100644 --- a/lib/get_cdr_export_fields +++ b/lib/get_cdr_export_fields @@ -22,12 +22,15 @@ [%- END %] [% MACRO cdr_timezone BLOCK -%] [% -source_subscriber_timezone = "(SELECT COALESCE(tz.name,@@global.time_zone) FROM billing.v_subscriber_timezone tz WHERE tz.uuid = accounting.cdr.source_user_id)"; -destination_subscriber_timezone = "(SELECT COALESCE(tz.name,@@global.time_zone) FROM billing.v_subscriber_timezone tz WHERE tz.uuid = accounting.cdr.destination_user_id)"; -transit_timezone = "(SELECT COALESCE(t.name,@@global.time_zone) FROM ngcp.timezone t LIMIT 1)"; +source_subscriber_timezone = "(SELECT COALESCE((SELECT tz.name FROM billing.v_subscriber_timezone tz WHERE tz.uuid = accounting.cdr.source_user_id LIMIT 1),@@global.time_zone))"; +destination_subscriber_timezone = "(SELECT COALESCE((SELECT tz.name FROM billing.v_subscriber_timezone tz WHERE tz.uuid = accounting.cdr.destination_user_id LIMIT 1),@@global.time_zone))"; +transit_timezone = "(SELECT COALESCE((SELECT t.name FROM ngcp.timezone t LIMIT 1),@@global.time_zone))"; -%] (IF(accounting.cdr.source_user_id = "0",IF(accounting.cdr.destination_user_id = "0",[%- transit_timezone -%],[%- destination_subscriber_timezone -%]),[%- source_subscriber_timezone -%])) [%- END %] +[% MACRO edr_timezone BLOCK -%] +(SELECT COALESCE((SELECT tz.name FROM billing.v_subscriber_timezone tz WHERE tz.subscriber_id = accounting.events.subscriber_id LIMIT 1),@@global.time_zone)) +[%- END %] [% MACRO from_unixtime_tz(column, timezone) BLOCK -%] CONVERT_TZ(FROM_UNIXTIME([%- column -%]),@@session.time_zone,[%- timezone -%]) [%- END %] @@ -129,6 +132,10 @@ X_cdr_id_map.PILOT_FIRST_NON_PRIMARY_ALIAS_USERNAME_BEFORE_AFTER = "IF(" _ edr_t X_cdr_id_map.TIMESTAMP = "from_unixtime(accounting.events.timestamp)"; +X_cdr_id_map.EVENT_TIMESTAMP = "CONCAT(FROM_UNIXTIME(FLOOR(accounting.events.timestamp)), \".\", SUBSTRING_INDEX(accounting.events.timestamp, \".\", -1)) as event_timestamp"; +X_cdr_id_map.EVENT_TIMEZONE = edr_timezone _ " as event_timezone"; +X_cdr_id_map.EVENT_TIMESTAMP_LOCALIZED = "CONCAT(" _ from_unixtime_tz("FLOOR(accounting.events.timestamp)",edr_timezone) _ ", \".\", SUBSTRING_INDEX(accounting.events.timestamp, \".\", -1)) as event_timestamp_localized"; + # Translate the fields. out.admin_fields = [];