
-- Current e2e test drafts:
select * from drafts3
where site_id = (select min(id) from sites3)
order by created_at desc;


-- See cached page html:
select
 site_id,
 page_id,
 width_layout,
 is_embedded,
 origin,
 cdn_origin,
 site_version,
 page_version,
 app_version,
 react_store_json_hash,
 updated_at
 from page_html3 where site_id = 3 and page_id = '72';


-- View identities w usernames, emails:
select * from identities3 i left join users3 u
  on i.site_id = u.site_id and i.user_id_c = u.user_id
  left join user_stats3 us
  on i.site_id = us.site_id and i.user_id_c = us.user_id
  where i.conf_file_idp_id_c = 'twitter'
    and i.site_id >= 1
    and u.primary_email_addr is null
  order by i.site_id;


-- View identities w usernames, emails, stats:
select * from identities3 i left join users3 u
on i.site_id = u.site_id and i.user_id_c = u.user_id
left join user_stats3 us
on i.site_id = us.site_id and i.user_id_c = us.user_id
where i.conf_file_idp_id_c = 'twitter'
and i.site_id >= 1
order by us.last_seen_at desc;



-- View notifications:
select n.*,
  (select username from users3 u where u.site_id = n.site_id and u.user_id = n.by_user_id) as by_username,
  (select username from users3 u where u.site_id = n.site_id and u.user_id = n.to_user_id) as to_username,
  (select approved_source from posts3 p where p.site_id = n.site_id and p.unique_post_id = n.unique_post_id) as post_approved_source
from notifications3 n
  where site_id = -18;


