diff --git a/tasks/dbt-monthly-channel-revenue/solution/solve.sh b/tasks/dbt-monthly-channel-revenue/solution/solve.sh index 0d0edcce..7bdeee11 100644 --- a/tasks/dbt-monthly-channel-revenue/solution/solve.sh +++ b/tasks/dbt-monthly-channel-revenue/solution/solve.sh @@ -636,7 +636,7 @@ with_consecutive_count as ( else row_number() over ( partition by channel, growth_group order by month_start - ) + ) - 1 end as consecutive_growth_months from with_growth_streak ), diff --git a/tasks/dbt-monthly-channel-revenue/tests/test_outputs.py b/tasks/dbt-monthly-channel-revenue/tests/test_outputs.py index 6f8ee323..073d3d80 100644 --- a/tasks/dbt-monthly-channel-revenue/tests/test_outputs.py +++ b/tasks/dbt-monthly-channel-revenue/tests/test_outputs.py @@ -256,9 +256,9 @@ def run_dbt(): EXPECTED_STRATEGIC_RECOMMENDATION_COUNTS = { 'Experiment': 15, - 'Scale Up': 13, + 'Scale Up': 14, 'Review': 12, - 'Invest Heavily': 3, + 'Invest Heavily': 2, 'Maintain': 3, 'Optimize': 2, 'Divest': 2, @@ -2015,54 +2015,54 @@ def test_january_web_first_month(self, dbt_run): ('2024-01-01', 'WEB', 1743.59, 1, 35.95, None, None, 0, 73, 58, 'Scale Up', 'Emerging'), ('2024-01-01', 'MOBILE', 1599.52, 2, 32.98, None, None, 0, 68, 50, 'Experiment', 'Emerging'), ('2024-01-01', 'PHONE', 1506.39, 3, 31.06, None, None, 0, 63, 66, 'Experiment', 'Emerging'), - ('2024-02-01', 'WEB', 2596.48, 1, 59.19, 48.92, 'Moderate Growth', 2, 90, 72, 'Scale Up', 'Market Leader'), + ('2024-02-01', 'WEB', 2596.48, 1, 59.19, 48.92, 'Moderate Growth', 1, 90, 72, 'Scale Up', 'Market Leader'), ('2024-02-01', 'MOBILE', 1302.64, 2, 29.69, -18.56, 'Slight Decline', 0, 58, 52, 'Optimize', 'Strong Performer'), ('2024-02-01', 'MARKETPLACE', 193.6, 3, 4.41, None, None, 0, 42, 50, 'Experiment', 'Emerging'), ('2024-02-01', 'POS', 177.2, 4, 4.04, None, None, 0, 37, 42, 'Monitor', 'Emerging'), ('2024-02-01', 'PHONE', 116.82, 5, 2.66, -92.25, 'Sharp Decline', 0, 12, 34, 'Review', 'At Risk'), - ('2024-03-01', 'WEB', 3721.58, 1, 42.91, 43.33, 'Moderate Growth', 3, 90, 63, 'Scale Up', 'Market Leader'), - ('2024-03-01', 'MOBILE', 3182.22, 2, 36.69, 144.29, 'Explosive', 2, 88, 80, 'Scale Up', 'Strong Performer'), - ('2024-03-01', 'MARKETPLACE', 959.59, 3, 11.06, 395.66, 'Explosive', 2, 69, 56, 'Experiment', 'Growth Potential'), - ('2024-03-01', 'POS', 809.45, 4, 9.33, 356.8, 'Explosive', 2, 57, 64, 'Experiment', 'Growth Potential'), - ('2024-04-01', 'WEB', 5606.65, 1, 74.69, 50.65, 'Strong Growth', 4, 100, 83, 'Invest Heavily', 'Market Leader'), + ('2024-03-01', 'WEB', 3721.58, 1, 42.91, 43.33, 'Moderate Growth', 2, 90, 63, 'Scale Up', 'Market Leader'), + ('2024-03-01', 'MOBILE', 3182.22, 2, 36.69, 144.29, 'Explosive', 1, 88, 80, 'Scale Up', 'Strong Performer'), + ('2024-03-01', 'MARKETPLACE', 959.59, 3, 11.06, 395.66, 'Explosive', 1, 69, 56, 'Experiment', 'Growth Potential'), + ('2024-03-01', 'POS', 809.45, 4, 9.33, 356.8, 'Explosive', 1, 57, 64, 'Experiment', 'Growth Potential'), + ('2024-04-01', 'WEB', 5606.65, 1, 74.69, 50.65, 'Strong Growth', 3, 100, 83, 'Invest Heavily', 'Market Leader'), ('2024-04-01', 'MOBILE', 1815.67, 2, 24.19, -42.94, 'Moderate Decline', 0, 41, 58, 'Review', 'At Risk'), ('2024-04-01', 'POS', 84.54, 3, 1.13, -89.56, 'Sharp Decline', 0, 22, 36, 'Review', 'At Risk'), - ('2024-05-01', 'MOBILE', 5959.91, 1, 53.38, 228.25, 'Explosive', 2, 100, 77, 'Scale Up', 'Market Leader'), + ('2024-05-01', 'MOBILE', 5959.91, 1, 53.38, 228.25, 'Explosive', 1, 100, 77, 'Scale Up', 'Market Leader'), ('2024-05-01', 'WEB', 3587.44, 2, 32.13, -36.01, 'Moderate Decline', 0, 48, 53, 'Review', 'At Risk'), - ('2024-05-01', 'POS', 1460.06, 3, 13.08, 1627.06, 'Explosive', 2, 69, 85, 'Experiment', 'Growth Potential'), + ('2024-05-01', 'POS', 1460.06, 3, 13.08, 1627.06, 'Explosive', 1, 69, 85, 'Experiment', 'Growth Potential'), ('2024-05-01', 'MARKETPLACE', 158.07, 4, 1.42, -83.53, 'Sharp Decline', 0, 17, 28, 'Divest', 'At Risk'), - ('2024-06-01', 'WEB', 3911.58, 1, 51.79, 9.04, 'Slight Growth', 2, 80, 65, 'Scale Up', 'Stable Core'), + ('2024-06-01', 'WEB', 3911.58, 1, 51.79, 9.04, 'Slight Growth', 1, 80, 65, 'Scale Up', 'Stable Core'), ('2024-06-01', 'MOBILE', 1643.11, 2, 21.75, -72.43, 'Sharp Decline', 0, 41, 57, 'Review', 'At Risk'), - ('2024-06-01', 'PHONE', 678.4, 3, 8.98, 480.72, 'Explosive', 2, 62, 72, 'Experiment', 'Growth Potential'), + ('2024-06-01', 'PHONE', 678.4, 3, 8.98, 480.72, 'Explosive', 1, 62, 72, 'Experiment', 'Growth Potential'), ('2024-06-01', 'POS', 669.22, 4, 8.86, -54.16, 'Sharp Decline', 0, 17, 46, 'Review', 'At Risk'), - ('2024-06-01', 'MARKETPLACE', 651.08, 5, 8.62, 311.89, 'Explosive', 2, 52, 47, 'Experiment', 'Growth Potential'), - ('2024-07-01', 'MOBILE', 7062.06, 1, 50.57, 329.8, 'Explosive', 2, 100, 82, 'Scale Up', 'Market Leader'), - ('2024-07-01', 'WEB', 4697.13, 2, 33.64, 20.08, 'Moderate Growth', 3, 78, 62, 'Scale Up', 'Strong Performer'), - ('2024-07-01', 'PHONE', 980.65, 3, 7.02, 44.55, 'Moderate Growth', 3, 52, 55, 'Maintain', 'Niche'), - ('2024-07-01', 'POS', 870.41, 4, 6.23, 30.06, 'Moderate Growth', 2, 47, 62, 'Maintain', 'Niche'), + ('2024-06-01', 'MARKETPLACE', 651.08, 5, 8.62, 311.89, 'Explosive', 1, 52, 47, 'Experiment', 'Growth Potential'), + ('2024-07-01', 'MOBILE', 7062.06, 1, 50.57, 329.8, 'Explosive', 1, 100, 82, 'Scale Up', 'Market Leader'), + ('2024-07-01', 'WEB', 4697.13, 2, 33.64, 20.08, 'Moderate Growth', 2, 78, 62, 'Scale Up', 'Strong Performer'), + ('2024-07-01', 'PHONE', 980.65, 3, 7.02, 44.55, 'Moderate Growth', 2, 52, 55, 'Maintain', 'Niche'), + ('2024-07-01', 'POS', 870.41, 4, 6.23, 30.06, 'Moderate Growth', 1, 47, 62, 'Maintain', 'Niche'), ('2024-07-01', 'MARKETPLACE', 354.27, 5, 2.54, -45.59, 'Moderate Decline', 0, 12, 39, 'Review', 'At Risk'), - ('2024-08-01', 'WEB', 5007.77, 1, 62.75, 6.61, 'Slight Growth', 4, 80, 78, 'Invest Heavily', 'Stable Core'), + ('2024-08-01', 'WEB', 5007.77, 1, 62.75, 6.61, 'Slight Growth', 3, 80, 78, 'Invest Heavily', 'Stable Core'), ('2024-08-01', 'MOBILE', 1420.27, 2, 17.80, -79.89, 'Sharp Decline', 0, 41, 46, 'Review', 'At Risk'), - ('2024-08-01', 'POS', 1314.18, 3, 16.47, 50.98, 'Strong Growth', 3, 76, 95, 'Experiment', 'Growth Potential'), + ('2024-08-01', 'POS', 1314.18, 3, 16.47, 50.98, 'Strong Growth', 2, 76, 95, 'Experiment', 'Growth Potential'), ('2024-08-01', 'MARKETPLACE', 237.75, 4, 2.98, -32.89, 'Moderate Decline', 0, 17, 33, 'Review', 'At Risk'), - ('2024-09-01', 'WEB', 5553.52, 1, 43.99, 10.9, 'Slight Growth', 5, 80, 55, 'Scale Up', 'Stable Core'), - ('2024-09-01', 'MOBILE', 2391.95, 2, 18.95, 68.42, 'Strong Growth', 2, 81, 75, 'Experiment', 'Growth Potential'), - ('2024-09-01', 'MARKETPLACE', 2346.62, 3, 18.59, 887.01, 'Explosive', 2, 76, 90, 'Experiment', 'Growth Potential'), - ('2024-09-01', 'POS', 2252.15, 4, 17.84, 71.37, 'Strong Growth', 4, 71, 79, 'Experiment', 'Growth Potential'), + ('2024-09-01', 'WEB', 5553.52, 1, 43.99, 10.9, 'Slight Growth', 4, 80, 55, 'Scale Up', 'Stable Core'), + ('2024-09-01', 'MOBILE', 2391.95, 2, 18.95, 68.42, 'Strong Growth', 1, 81, 75, 'Experiment', 'Growth Potential'), + ('2024-09-01', 'MARKETPLACE', 2346.62, 3, 18.59, 887.01, 'Explosive', 1, 76, 90, 'Experiment', 'Growth Potential'), + ('2024-09-01', 'POS', 2252.15, 4, 17.84, 71.37, 'Strong Growth', 3, 71, 79, 'Experiment', 'Growth Potential'), ('2024-09-01', 'PHONE', 80.16, 5, 0.63, -91.83, 'Sharp Decline', 0, 12, 25, 'Divest', 'At Risk'), ('2024-10-01', 'WEB', 4921.0, 1, 57.85, -11.39, 'Slight Decline', 0, 70, 80, 'Scale Up', 'Stable Core'), ('2024-10-01', 'MOBILE', 2103.29, 2, 24.73, -12.07, 'Slight Decline', 0, 51, 83, 'Optimize', 'Stable Core'), ('2024-10-01', 'POS', 933.79, 3, 10.98, -58.54, 'Sharp Decline', 0, 29, 65, 'Review', 'At Risk'), ('2024-10-01', 'MARKETPLACE', 548.21, 4, 6.44, -76.64, 'Sharp Decline', 0, 17, 47, 'Review', 'At Risk'), - ('2024-11-01', 'WEB', 10592.76, 1, 62.24, 115.26, 'Explosive', 2, 100, 92, 'Scale Up', 'Market Leader'), - ('2024-11-01', 'MOBILE', 3983.58, 2, 23.41, 89.4, 'Strong Growth', 2, 81, 74, 'Scale Up', 'Growth Potential'), - ('2024-11-01', 'MARKETPLACE', 1413.69, 3, 8.31, 157.87, 'Explosive', 2, 62, 52, 'Experiment', 'Growth Potential'), - ('2024-11-01', 'PHONE', 1029.87, 4, 6.05, 1184.77, 'Explosive', 2, 57, 90, 'Experiment', 'Growth Potential'), + ('2024-11-01', 'WEB', 10592.76, 1, 62.24, 115.26, 'Explosive', 1, 100, 92, 'Scale Up', 'Market Leader'), + ('2024-11-01', 'MOBILE', 3983.58, 2, 23.41, 89.4, 'Strong Growth', 1, 81, 74, 'Scale Up', 'Growth Potential'), + ('2024-11-01', 'MARKETPLACE', 1413.69, 3, 8.31, 157.87, 'Explosive', 1, 62, 52, 'Experiment', 'Growth Potential'), + ('2024-11-01', 'PHONE', 1029.87, 4, 6.05, 1184.77, 'Explosive', 1, 57, 90, 'Experiment', 'Growth Potential'), ('2024-12-01', 'WEB', 9717.15, 1, 46.43, -8.27, 'Slight Decline', 0, 70, 67, 'Scale Up', 'Stable Core'), - ('2024-12-01', 'MOBILE', 6913.11, 2, 33.03, 73.54, 'Strong Growth', 3, 88, 72, 'Invest Heavily', 'Strong Performer'), - ('2024-12-01', 'PHONE', 1884.08, 3, 9.0, 82.94, 'Strong Growth', 3, 62, 87, 'Experiment', 'Growth Potential'), + ('2024-12-01', 'MOBILE', 6913.11, 2, 33.03, 73.54, 'Strong Growth', 2, 88, 72, 'Scale Up', 'Strong Performer'), + ('2024-12-01', 'PHONE', 1884.08, 3, 9.0, 82.94, 'Strong Growth', 2, 62, 87, 'Experiment', 'Growth Potential'), ('2024-12-01', 'MARKETPLACE', 1217.83, 4, 5.82, -13.85, 'Slight Decline', 0, 27, 54, 'Review', 'Niche'), - ('2024-12-01', 'POS', 1198.26, 5, 5.72, 28.32, 'Moderate Growth', 2, 42, 49, 'Maintain', 'Niche'), + ('2024-12-01', 'POS', 1198.26, 5, 5.72, 28.32, 'Moderate Growth', 1, 42, 49, 'Maintain', 'Niche'), ]