Skip to content

Instantly share code, notes, and snippets.

@scmmishra
Created June 15, 2023 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scmmishra/0228fe37085c5c66cb4e9b5b3682c0f5 to your computer and use it in GitHub Desktop.
Save scmmishra/0228fe37085c5c66cb4e9b5b3682c0f5 to your computer and use it in GitHub Desktop.
time_zone = '<YourTimezone>'
account_id = '<YourAccountID>'
start_date = Time.zone.now - 12.days
end_date = Time.zone.now
a = Account.find(account_id)
outlier_events = a.reporting_events.where(created_at: start_date..end_date, name: 'conversation_resolved').order(value: :desc).limit(30)
outlier_events.each do |event|
puts "Conversation ##{event.conversation.display_id}, created on #{event.conversation.created_at.strftime('%Y-%m-%d')} took #{(event.value / 1.day).round(0)} days"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment