--  queries uteis para visualização das informações do AMID
--  (no DBeaver, abrir com SQL new console e executar)

-- Informações das calls
SELECT
    c.call_uniqueid AS call_name,
    c.call_type,
    c.init_date, 
    ch1.name AS caller_channel,
    ch2.name AS callee_channel,
    p1.callerid_number AS caller_peer,
    p2.callerid_number AS callee_peer
FROM `call` AS c
LEFT JOIN channel AS ch1 ON c.caller_channel_id = ch1.id
LEFT JOIN channel AS ch2 ON c.callee_channel_id = ch2.id
LEFT JOIN peer AS p1 ON ch1.peer_id = p1.id
LEFT JOIN peer AS p2 ON ch2.peer_id = p2.id

-- Visualizar bridges e pontes 
   SELECT
   	bm.id,
    b.uniqueid AS bridge_name,
    ch.name AS channel_name,
    p.callerid_number  AS peer_name
FROM
    bridge_member bm
LEFT JOIN
    bridge b ON b.id = bm.bridge_id
LEFT JOIN
    channel ch ON ch.id  = bm.id
LEFT JOIN
    peer p ON p.id = ch.peer_id;