Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New parents subscriptions query #1339

Merged
merged 3 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions apps/alert_processor/lib/model/query.ex
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,18 @@ defmodule AlertProcessor.Model.Query do
UNION ALL
SELECT 'Paused for 12 months or more',plmore.total_paused_accounts FROM paused_for_twelve_months_or_more plmore;
"""
},
%__MODULE__{
label: "Count of Active Users Having Subscriptions That Are Parents",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought (non-blocking): I wonder if there's some wording that makes this label more generally understandable / less specific to the implementation details. Maybe something along the lines of, "parallel route subscriptions"?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or even, "parallel bus route subscriptions" since this is only possible with bus routes?

query: """
SELECT COUNT(DISTINCT user_id) AS users_with_parent_subscriptions
FROM subscriptions
WHERE id IN
(SELECT parent_id FROM subscriptions
WHERE parent_id IS NOT null
AND paused is not true
GROUP BY parent_id)
"""
}
]
|> Enum.map(&%{&1 | id: &1.label |> String.downcase() |> String.replace(" ", "_")})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,25 +206,39 @@ defmodule AlertProcessor.ServiceInfoCacheTest do
assert [
%AlertProcessor.Model.Route{
direction_names: ["Outbound", "Inbound"],
direction_destinations: ["Charlestown", "Long Wharf"],
headsigns: nil,
long_name: "Charlestown Ferry",
order: 0,
route_id: "Boat-F4",
route_type: 4,
short_name: ""
short_name: "",
stop_list: [
{"Charlestown Navy Yard", "Boat-Charlestown", {42.372756, -71.052528}, 1},
{"Long Wharf (South)", "Boat-Long-South", {42.359448, -71.050498}, 1}
]
},
%AlertProcessor.Model.Route{
direction_names: ["Outbound", "Inbound"],
direction_destinations: ["Hingham or Hull", "Long Wharf or Rowes Wharf"],
headsigns: nil,
long_name: "Hingham/Hull Ferry",
order: 1,
route_id: "Boat-F1",
route_type: 4,
short_name: ""
short_name: "",
stop_list: [
{"Hingham", "Boat-Hingham", {42.253956, -70.919844}, 1},
{"Rowes Wharf", "Boat-Rowes", {42.355721, -71.049897}, 1},
{"Georges Island", "Boat-George", {42.319742, -70.930427}, 1},
{"Hull", "Boat-Hull", {42.303251, -70.920215}, 1},
{"Logan Airport Ferry Terminal", "Boat-Logan", {42.359789, -71.02734}, 1},
{"Long Wharf (North)", "Boat-Long", {42.360795, -71.049976}, 1}
]
},
%AlertProcessor.Model.Route{
direction_destinations: ["Lewis Mall Wharf", "Long Wharf"],
direction_names: ["Outbound", "Inbound"],
direction_destinations: ["Lewis Mall Wharf", "Long Wharf"],
headsigns: nil,
long_name: "East Boston Ferry",
order: 2,
Expand Down Expand Up @@ -263,7 +277,7 @@ defmodule AlertProcessor.ServiceInfoCacheTest do
{"Winthrop Landing", "Boat-Winthrop", {42.366711, -70.973302}, 1},
{"Quincy", "Boat-Quincy", {42.30132, -71.03201}, 1},
{"Logan Airport Ferry Terminal", "Boat-Logan", {42.359789, -71.02734}, 1},
{"Fan Pier", "Boat-Fan", {42.353484, -71.04323}, 1},
{"Seaport/Fan Pier", "Boat-Fan", {42.353484, -71.04323}, 1},
{"Central Wharf (South)", "Boat-Aquarium", {42.358815, -71.048779}, 1}
]
}
Expand Down