Skip to content

Commit 470a97d

Browse files
ylyangtwsandeep-ps
andauthored
305 feature add endpoints proposals and current to support new model h (#308)
* add endpoints for H model * updated json files * Compress data * update json * Update pdl.py * Update pdl.py * fix NaN * fix FIPS * update * Update app/pdl.yaml Co-authored-by: Sandeep Puthanveetil Satheesan <sandeeps@illinois.edu> * Update app/pdl.yaml Co-authored-by: Sandeep Puthanveetil Satheesan <sandeeps@illinois.edu> * Update app/pdl.yaml Co-authored-by: Sandeep Puthanveetil Satheesan <sandeeps@illinois.edu> * Update app/pdl.yaml Co-authored-by: Sandeep Puthanveetil Satheesan <sandeeps@illinois.edu> * Added percentage * Update pdl.yaml --------- Co-authored-by: Sandeep Puthanveetil Satheesan <sandeeps@illinois.edu>
1 parent 699eaf4 commit 470a97d

File tree

5 files changed

+72
-1
lines changed

5 files changed

+72
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
### Added
2020
- Add back summary endpoint to SNAP. [#271](https://github.com/policy-design-lab/pdl-api/issues/271)
2121
- Add top-level endpoints to Title-II. [#270](https://github.com/policy-design-lab/pdl-api/issues/270)
22+
- Add endpoints (proposals and current) to support new model H. [#305](https://github.com/policy-design-lab/pdl-api/issues/305)
2223

2324
### Changed
2425
- Change house api path. [#295](https://github.com/policy-design-lab/pdl-api/issues/295)
3.98 MB
Binary file not shown.
3.72 MB
Binary file not shown.

app/controllers/pdl.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import gzip
12
import json
23
import logging
34
import os
45
from collections import OrderedDict
5-
from flask import request
6+
from flask import request, Response
67
from sqlalchemy import func, desc, Numeric, BigInteger, Integer, text, or_, and_
78

89
import app.utils.jsonutils as jsonutils
@@ -29,6 +30,9 @@
2930
COMMOD_MAP_DATA_JSON = "commodities_map_data.json"
3031
COMMOD_STATE_DISTRIBUTION_DATA_JSON = "commodities_state_distribution_data.json"
3132
COMMOD_SUBPROGRAMS_DATA_JSON = "commodities_subprograms_data.json"
33+
ARC_PLC_DATA_JSON = "arc_plc_payments_Current.json.gz"
34+
I_PROPOSALS_SUBTITLE_A_DATA_PATH = os.path.join(TITLE_I_DATA_PATH, "proposals", "subtitle-a")
35+
ARC_PLC_PROPOSAL_DATA_JSON = "arc_plc_payments_Proposed.json.gz"
3236
I_SUBTITLE_D_DATA_PATH = os.path.join(TITLE_I_DATA_PATH, "subtitle-d")
3337
DMC_STATE_DISTRIBUTION_DATA_JSON = "dmc_state_distribution_data.json"
3438
DMC_SUBPROGRAMS_DATA_JSON = "dmc_subprograms_data.json"
@@ -437,6 +441,32 @@ def titles_title_i_subtitles_subtitle_e_summary_search():
437441
return endpoint_response
438442

439443

444+
# /pdl/titles/title-i/subtitles/subtitle-a/arc-plc-payments/current
445+
def titles_title_i_subtitles_subtitle_a_arc_plc_payments_current_search():
446+
# set the file path
447+
arc_plc_current_data = os.path.join(I_SUBTITLE_A_DATA_PATH, ARC_PLC_DATA_JSON)
448+
449+
with open(arc_plc_current_data, 'rb') as current_data:
450+
file_data = current_data.read()
451+
452+
response = Response(file_data, mimetype='application/json')
453+
response.headers['Content-Encoding'] = 'gzip'
454+
return response
455+
456+
457+
# /pdl/titles/title-i/subtitles/subtitle-a/arc-plc-payments/proposed
458+
def titles_title_i_subtitles_subtitle_a_arc_plc_payments_proposed_search():
459+
# set the file path
460+
arc_plc_proposed_data = os.path.join(I_PROPOSALS_SUBTITLE_A_DATA_PATH, ARC_PLC_PROPOSAL_DATA_JSON)
461+
462+
with open(arc_plc_proposed_data, 'rb') as proposed_data:
463+
file_data = proposed_data.read()
464+
465+
response = Response(file_data, mimetype='application/json')
466+
response.headers['Content-Encoding'] = 'gzip'
467+
return response
468+
469+
440470
# /pdl/titles/title-ii/summary:
441471
def titles_title_ii_summary_search():
442472
title_id = get_title_id(TITLE_II_NAME)

app/pdl.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,46 @@ paths:
369369
description: Unauthorized
370370
500:
371371
description: Internal error
372+
/pdl/titles/title-i/subtitles/subtitle-a/arc-plc-payments/current:
373+
get:
374+
tags:
375+
- "Title I: Commodities - Subtitle A"
376+
summary: Gets the current Title I Subtitle A commodities payment distribution for ARC and PLC.
377+
description: |
378+
Returns the current Title I Subtitle A commodities payment distribution data for ARC and PLC in JSON format.
379+
responses:
380+
200:
381+
description: Ok
382+
content:
383+
application/json:
384+
schema:
385+
type: string
386+
400:
387+
description: Bad request
388+
401:
389+
description: Unauthorized
390+
500:
391+
description: Internal error
392+
/pdl/titles/title-i/subtitles/subtitle-a/arc-plc-payments/proposed:
393+
get:
394+
tags:
395+
- "Title I: Commodities - Subtitle A"
396+
summary: Gets the projected Title I Subtitle A commodities payment distribution data ARC and PLC.
397+
description: |
398+
Returns the projected Title I Subtitle A commodities payment distribution for ARC and PLC in JSON format.
399+
responses:
400+
200:
401+
description: Ok
402+
content:
403+
application/json:
404+
schema:
405+
type: string
406+
400:
407+
description: Bad request
408+
401:
409+
description: Unauthorized
410+
500:
411+
description: Internal error
372412
/pdl/titles/title-i/subtitles/subtitle-d/state-distribution:
373413
get:
374414
tags:

0 commit comments

Comments
 (0)