Skip to content

Commit 10f1d46

Browse files
authored
Update all program keys format (#340)
1 parent 61fe6c5 commit 10f1d46

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Changed
10+
- Change all programs key from YY-YY format (start and end years) to YYYY-YYYY format. [#272](https://github.com/policy-design-lab/pdl-api/issues/272)
11+
912
### Added
1013
- Add endpoint for ARC PLC reconciliation policy. [#332](https://github.com/policy-design-lab/pdl-api/issues/332)
1114

app/controllers/pdl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,7 @@ def generate_allprograms_response(start_year, end_year):
12681268
SUM(CASE WHEN t.name = 'Title II: Conservation' AND p.year BETWEEN {start_year} AND {end_year} AND (sub_program_id IN (SELECT id FROM pdl.sub_programs WHERE pdl.sub_programs.name = 'Total CRP') OR sub_program_id IS NULL) THEN p.payment ELSE 0 END) AS "Title II Total",
12691269
SUM(CASE WHEN t.name = 'Title IV: Nutrition' AND p.year BETWEEN {start_year} AND {end_year} THEN p.payment ELSE 0 END) AS "SNAP Total",
12701270
SUM(CASE WHEN t.name = 'Title IX: Crop Insurance' AND p.year BETWEEN {start_year} AND {end_year} THEN p.net_farmer_benefit_amount ELSE 0 END) AS "Crop Insurance Total",
1271-
SUM(CASE WHEN (sub_program_id IN (SELECT id FROM pdl.sub_programs WHERE pdl.sub_programs.name IN ('Total CRP', 'Agriculture Risk Coverage County Option (ARC-CO)', 'Agriculture Risk Coverage Individual Coverage (ARC-IC)')) OR sub_program_id IS NULL) THEN COALESCE(p.payment, 0) + COALESCE(p.net_farmer_benefit_amount, 0) ELSE 0 END) AS "{str(start_year)[-2:]}-{str(end_year)[-2:]} All Programs Total"
1271+
SUM(CASE WHEN (sub_program_id IN (SELECT id FROM pdl.sub_programs WHERE pdl.sub_programs.name IN ('Total CRP', 'Agriculture Risk Coverage County Option (ARC-CO)', 'Agriculture Risk Coverage Individual Coverage (ARC-IC)')) OR sub_program_id IS NULL) THEN COALESCE(p.payment, 0) + COALESCE(p.net_farmer_benefit_amount, 0) ELSE 0 END) AS "{str(start_year)}-{str(end_year)} All Programs Total"
12721272
"""
12731273

12741274
# Combine the query of non-dynamic part
@@ -1293,7 +1293,7 @@ def generate_allprograms_response(start_year, end_year):
12931293

12941294
state_data = []
12951295
total_row = {"State": "Total"}
1296-
start_to_end_years_total_key = str(start_year)[-2:] + "-" + str(end_year)[-2:] + " All Programs Total"
1296+
start_to_end_years_total_key = str(start_year) + "-" + str(end_year) + " All Programs Total"
12971297

12981298
# Initialize total_row with zero values for all keys in the desired order
12991299
for year in range(start_year, end_year + 1):

0 commit comments

Comments
 (0)