У меня довольно мало опыта работы с json в Postgres, и это очень затрудняет получение нужных мне данных. Используя запрос ниже, я вижу, что callflow
дает мне время для каждого раздела вызова. Могу ли я получить times
, где hangup_time
больше нуля? В идеале мне просто нужно время в секундах между created_time
и hangup_time
для каждой строки.
select
xml_cdr_uuid,
json->'callflow'
from fusionpbx.public.v_xml_cdr
where start_stamp > now() - '1 day'::interval;
, что дает мне такие массивы времени для каждой строки.
[
{
"times":
{
"hangup_time": "1588604603083829",
"bridged_time": "1588604592603811",
"created_time": "1588604575783849",
"answered_time": "1588604575803817",
"progress_time": "1588604575803817",
"transfer_time": "0",
"last_hold_time": "0",
"resurrect_time": "0",
"hold_accum_time": "0",
"progress_media_time": "0",
"profile_created_time": "1588604582343873"
},
"extension": {...},
"@attributes": {...},
"caller_profile": {...},
},
{
"times":
{
"hangup_time": "0",
"bridged_time": "0",
"created_time": "1588604575783849",
"answered_time": "1588604575803817",
"progress_time": "1588604575803817",
"transfer_time": "1588604582343873",
"last_hold_time": "0",
"resurrect_time": "0",
"hold_accum_time": "0",
"progress_media_time": "0",
"profile_created_time": "1588604575783849"
},
"extension": {...},
"@attributes": {...},
"caller_profile": {...},
},
{
"times":
{
"hangup_time": "0",
"bridged_time": "0",
"created_time": "1588604575783849",
"answered_time": "0",
"progress_time": "0",
"transfer_time": "1588604575783849",
"last_hold_time": "0",
"resurrect_time": "0",
"hold_accum_time": "0",
"progress_media_time": "0",
"profile_created_time": "1588604575783849"
},
"extension": {...},
"@attributes": {...},
"caller_profile": {...},
}
]