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
changes/78/18778/4
Rene Krenn 8 years ago
parent 6aba809216
commit c3d0b6267d

@ -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 = [];

Loading…
Cancel
Save