1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2025-04-05 00:27:25 +00:00
mailinabox/management/reporting/uidata/user_activity.3.sql

23 lines
576 B
SQL

--
-- imap connection summary
--
SELECT
count(*) as `count`,
disposition,
CASE WHEN remote_host='unknown' THEN remote_ip ELSE remote_host END AS `remote_host`,
sum(in_bytes) as `in_bytes`,
sum(out_bytes) as `out_bytes`,
min(connect_time) as `first_connection_time`,
max(connect_time) as `last_connection_time`
FROM
imap_connection
WHERE
sasl_username = :user_id AND
connect_time >= :start_date AND
connect_time < :end_date
GROUP BY
disposition,
CASE WHEN remote_host='unknown' THEN remote_ip ELSE remote_host END
ORDER BY
`count` DESC, disposition