Skip to content

Instantly share code, notes, and snippets.

@jaymay
Last active August 29, 2015 14:19
Show Gist options
  • Save jaymay/611d18decdef95f4c473 to your computer and use it in GitHub Desktop.
Save jaymay/611d18decdef95f4c473 to your computer and use it in GitHub Desktop.
uber agent actions
use classic;
select
e.delta_date run_at,
e.account_id,
e.author_id AS agent_id,
ui.value as email,
if(u.roles = 2, 1, 0) as is_admin,
count(*) as num_actions
from classic.events e
left outer join classic.users u ON e.author_id = u.id
left outer join classic.user_identities ui on ui.user_id = e.author_id and ui.priority = 1 and ui.type = 'UserEmailIdentity'
where e.author_id > 0
and e.type in ('Audit')
and u.roles in (2, 4)
and e.account_id = 34989
and e.delta_date between 20150301 and 20150331
group by
e.delta_date,
e.account_id,
e.author_id,
ui.value,
if(u.roles = 2, 1, 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment