From 34d8dd2ae6aeb12b0b4f378e9a5146d23861b042 Mon Sep 17 00:00:00 2001 From: Erin Moore Date: Tue, 11 Jul 2023 15:32:18 -0400 Subject: [PATCH 1/3] New parents subscriptions query --- apps/alert_processor/lib/model/query.ex | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/alert_processor/lib/model/query.ex b/apps/alert_processor/lib/model/query.ex index 9ddbe8bd7..2f62b63cd 100644 --- a/apps/alert_processor/lib/model/query.ex +++ b/apps/alert_processor/lib/model/query.ex @@ -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", + 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(" ", "_")}) From db879a05f1f0dcdd37c2dfe0ee83fc5c0abd7714 Mon Sep 17 00:00:00 2001 From: Erin Moore Date: Fri, 14 Jul 2023 08:46:43 -0400 Subject: [PATCH 2/3] fix broken test --- .../service_info/service_info_cache_test.exs | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/apps/alert_processor/test/alert_processor/service_info/service_info_cache_test.exs b/apps/alert_processor/test/alert_processor/service_info/service_info_cache_test.exs index cd58f1f38..9de4eceba 100644 --- a/apps/alert_processor/test/alert_processor/service_info/service_info_cache_test.exs +++ b/apps/alert_processor/test/alert_processor/service_info/service_info_cache_test.exs @@ -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, @@ -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} ] } From fef845d05e20fa9cd63155c3bd1e29397202580a Mon Sep 17 00:00:00 2001 From: Erin Moore Date: Mon, 17 Jul 2023 12:11:21 -0400 Subject: [PATCH 3/3] rename --- apps/alert_processor/lib/model/query.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/alert_processor/lib/model/query.ex b/apps/alert_processor/lib/model/query.ex index 2f62b63cd..0e49ab8e0 100644 --- a/apps/alert_processor/lib/model/query.ex +++ b/apps/alert_processor/lib/model/query.ex @@ -236,9 +236,9 @@ defmodule AlertProcessor.Model.Query do """ }, %__MODULE__{ - label: "Count of Active Users Having Subscriptions That Are Parents", + label: "Count of Users With Parallel Bus Route Subscriptions", query: """ - SELECT COUNT(DISTINCT user_id) AS users_with_parent_subscriptions + SELECT COUNT(DISTINCT user_id) AS users_with_parallel_subscriptions FROM subscriptions WHERE id IN (SELECT parent_id FROM subscriptions