Skip to content

Instantly share code, notes, and snippets.

@alicethewhale
Created November 22, 2018 16:24
Show Gist options
  • Save alicethewhale/4467e47ac31a8742312a12729cb11caf to your computer and use it in GitHub Desktop.
Save alicethewhale/4467e47ac31a8742312a12729cb11caf to your computer and use it in GitHub Desktop.
lead_alerts_query = LeadAlert.timeline_subquery(lead)
completed_lead_alerts_query = CompletedLeadAlert.timeline_subquery(lead)
notes_query = Note.timeline_subquery(lead)
transitions_query = LeadTransition.timeline_subquery(lead)
union_query = [lead_alerts_query, completed_lead_alerts_query, notes_query, transitions_query].map(&:to_sql).join(" UNION ALL ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment