Skip to content

Commit

Permalink
adds multiple trips query (#1341)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Shanley <[email protected]>
  • Loading branch information
ErinLMoore and arkadyan authored Jul 19, 2023
1 parent 167a6aa commit 9249c20
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions apps/alert_processor/lib/model/query.ex
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,20 @@ defmodule AlertProcessor.Model.Query do
GROUP BY parent_id)
AND u.communication_mode != 'none'
"""
},
%__MODULE__{
label: "Count of Active Users By Number of Active Trips",
query: """
select trip_count, count(user_id) as users
from (
select t.user_id as user_id, count(distinct t.id) as trip_count
from trips t
join subscriptions s
on s.trip_id = t.id and s.paused = false
group by t.user_id
) as user_trip_counts
group by trip_count;
"""
}
]
|> Enum.map(&%{&1 | id: &1.label |> String.downcase() |> String.replace(" ", "_")})
Expand Down

0 comments on commit 9249c20

Please sign in to comment.