91
91
TITLE_IV_SNAP_PROGRAM_NAME = "Supplemental Nutrition Assistance Program (SNAP)"
92
92
TITLE_XI_CROP_INSURANCE_PROGRAM_NAME = "Crop Insurance"
93
93
94
+ TITLE_II_START_YEAR = 2014
95
+ TITLE_II_END_YEAR = 2023
96
+
94
97
95
98
def search ():
96
99
out_json = jsonutils .create_test_message ()
@@ -433,21 +436,34 @@ def titles_title_i_subtitles_subtitle_e_summary_search():
433
436
endpoint_response = generate_title_i_summary_response (subtitle_id , start_year , end_year )
434
437
return endpoint_response
435
438
439
+
436
440
# /pdl/titles/title-ii/summary:
437
441
def titles_title_ii_summary_search ():
438
- start_year = 2018
439
- end_year = 2022
440
- title_id = 101
441
- endpoint_response = generate_title_ii_total_summary_response (title_id , start_year , end_year )
442
+ title_id = get_title_id (TITLE_II_NAME )
443
+ if title_id is None :
444
+ msg = {
445
+ "reason" : "No record for the given title name " + TITLE_II_NAME ,
446
+ "error" : "Not found: " + request .url ,
447
+ }
448
+ logging .error ("Title II: " + json .dumps (msg ))
449
+ return rs_handlers .not_found (msg )
450
+
451
+ endpoint_response = generate_title_ii_total_summary_response (title_id , TITLE_II_START_YEAR , TITLE_II_END_YEAR )
442
452
return endpoint_response
443
453
444
454
445
455
# /pdl/titles/title-ii/state-distribution:
446
456
def titles_title_ii_state_distribution_search ():
447
- start_year = 2018
448
- end_year = 2022
449
- title_id = 101
450
- endpoint_response = generate_title_ii_total_state_distribution_response (title_id , start_year , end_year )
457
+ title_id = get_title_id (TITLE_II_NAME )
458
+ if title_id is None :
459
+ msg = {
460
+ "reason" : "No record for the given title name " + TITLE_II_NAME ,
461
+ "error" : "Not found: " + request .url ,
462
+ }
463
+ logging .error ("Title II: " + json .dumps (msg ))
464
+ return rs_handlers .not_found (msg )
465
+
466
+ endpoint_response = generate_title_ii_total_state_distribution_response (title_id , TITLE_II_START_YEAR , TITLE_II_END_YEAR )
451
467
return endpoint_response
452
468
453
469
# /pdl/titles/title-ii/programs/eqip/map
@@ -476,9 +492,7 @@ def titles_title_ii_programs_eqip_state_distribution_search(practice_code=None):
476
492
logging .error ("EQIP: " + json .dumps (msg ))
477
493
return rs_handlers .not_found (msg )
478
494
479
- start_year = 2018
480
- end_year = 2022
481
- endpoint_response = generate_title_ii_state_distribution_response (program_id , start_year , end_year , practice_code = practice_code )
495
+ endpoint_response = generate_title_ii_state_distribution_response (program_id , TITLE_II_START_YEAR , TITLE_II_END_YEAR , practice_code = practice_code )
482
496
return endpoint_response
483
497
484
498
@@ -492,9 +506,8 @@ def titles_title_ii_programs_eqip_summary_search():
492
506
}
493
507
logging .error ("EQIP: " + json .dumps (msg ))
494
508
return rs_handlers .not_found (msg )
495
- start_year = 2018
496
- end_year = 2022
497
- endpoint_response = generate_title_ii_summary_response (program_id , start_year , end_year )
509
+
510
+ endpoint_response = generate_title_ii_summary_response (program_id , TITLE_II_START_YEAR , TITLE_II_END_YEAR )
498
511
return endpoint_response
499
512
500
513
@@ -508,9 +521,8 @@ def titles_title_ii_programs_eqip_practice_names_search():
508
521
}
509
522
logging .error ("EQIP: " + json .dumps (msg ))
510
523
return rs_handlers .not_found (msg )
511
- start_year = 2018
512
- end_year = 2022
513
- endpoint_response = generate_title_ii_practice_names_response (program_id , start_year , end_year )
524
+
525
+ endpoint_response = generate_title_ii_practice_names_response (program_id , TITLE_II_START_YEAR , TITLE_II_END_YEAR )
514
526
return endpoint_response
515
527
516
528
@@ -599,9 +611,8 @@ def titles_title_ii_programs_csp_state_distribution_search(practice_code=None):
599
611
}
600
612
logging .error ("CSP: " + json .dumps (msg ))
601
613
return rs_handlers .not_found (msg )
602
- start_year = 2018
603
- end_year = 2022
604
- endpoint_response = generate_title_ii_state_distribution_response (program_id , start_year , end_year , practice_code = practice_code )
614
+
615
+ endpoint_response = generate_title_ii_state_distribution_response (program_id , TITLE_II_START_YEAR , TITLE_II_END_YEAR , practice_code = practice_code )
605
616
return endpoint_response
606
617
607
618
@@ -615,9 +626,8 @@ def titles_title_ii_programs_csp_summary_search():
615
626
}
616
627
logging .error ("CSP: " + json .dumps (msg ))
617
628
return rs_handlers .not_found (msg )
618
- start_year = 2018
619
- end_year = 2022
620
- endpoint_response = generate_title_ii_summary_response (program_id , start_year , end_year )
629
+
630
+ endpoint_response = generate_title_ii_summary_response (program_id , TITLE_II_START_YEAR , TITLE_II_END_YEAR )
621
631
return endpoint_response
622
632
623
633
@@ -631,9 +641,8 @@ def titles_title_ii_programs_csp_practice_names_search():
631
641
}
632
642
logging .error ("EQIP: " + json .dumps (msg ))
633
643
return rs_handlers .not_found (msg )
634
- start_year = 2018
635
- end_year = 2022
636
- endpoint_response = generate_title_ii_practice_names_response (program_id , start_year , end_year )
644
+
645
+ endpoint_response = generate_title_ii_practice_names_response (program_id , TITLE_II_START_YEAR , TITLE_II_END_YEAR )
637
646
return endpoint_response
638
647
639
648
@@ -696,6 +705,7 @@ def titles_title_ii_programs_csp_ira_predicted_search():
696
705
697
706
return data_json
698
707
708
+
699
709
# /pdl/titles/title-ii/programs/crp/state-distribution
700
710
def titles_title_ii_programs_crp_state_distribution_search ():
701
711
program_id = get_program_id (TITLE_II_CRP_PROGRAM_NAME )
@@ -706,9 +716,8 @@ def titles_title_ii_programs_crp_state_distribution_search():
706
716
}
707
717
logging .error ("CRP: " + json .dumps (msg ))
708
718
return rs_handlers .not_found (msg )
709
- start_year = 2018
710
- end_year = 2022
711
- endpoint_response = generate_title_ii_state_distribution_response (program_id , start_year , end_year )
719
+
720
+ endpoint_response = generate_title_ii_state_distribution_response (program_id , TITLE_II_START_YEAR , TITLE_II_END_YEAR )
712
721
return endpoint_response
713
722
714
723
@@ -722,9 +731,8 @@ def titles_title_ii_programs_crp_summary_search():
722
731
}
723
732
logging .error ("CRP: " + json .dumps (msg ))
724
733
return rs_handlers .not_found (msg )
725
- start_year = 2018
726
- end_year = 2022
727
- endpoint_response = generate_title_ii_summary_response (program_id , start_year , end_year )
734
+
735
+ endpoint_response = generate_title_ii_summary_response (program_id , TITLE_II_START_YEAR , TITLE_II_END_YEAR )
728
736
return endpoint_response
729
737
730
738
@@ -738,9 +746,8 @@ def titles_title_ii_programs_acep_state_distribution_search():
738
746
}
739
747
logging .error ("ACEP: " + json .dumps (msg ))
740
748
return rs_handlers .not_found (msg )
741
- start_year = 2018
742
- end_year = 2022
743
- endpoint_response = generate_title_ii_state_distribution_response (program_id , start_year , end_year )
749
+
750
+ endpoint_response = generate_title_ii_state_distribution_response (program_id , TITLE_II_START_YEAR , TITLE_II_END_YEAR )
744
751
return endpoint_response
745
752
746
753
@@ -754,9 +761,8 @@ def titles_title_ii_programs_acep_summary_search():
754
761
}
755
762
logging .error ("ACEP: " + json .dumps (msg ))
756
763
return rs_handlers .not_found (msg )
757
- start_year = 2018
758
- end_year = 2022
759
- endpoint_response = generate_title_ii_summary_response (program_id , start_year , end_year )
764
+
765
+ endpoint_response = generate_title_ii_summary_response (program_id , TITLE_II_START_YEAR , TITLE_II_END_YEAR )
760
766
return endpoint_response
761
767
762
768
@@ -770,9 +776,8 @@ def titles_title_ii_programs_rcpp_state_distribution_search():
770
776
}
771
777
logging .error ("RCPP: " + json .dumps (msg ))
772
778
return rs_handlers .not_found (msg )
773
- start_year = 2018
774
- end_year = 2022
775
- endpoint_response = generate_title_ii_state_distribution_response (program_id , start_year , end_year )
779
+
780
+ endpoint_response = generate_title_ii_state_distribution_response (program_id , TITLE_II_START_YEAR , TITLE_II_END_YEAR )
776
781
return endpoint_response
777
782
778
783
@@ -786,9 +791,8 @@ def titles_title_ii_programs_rcpp_summary_search():
786
791
}
787
792
logging .error ("RCPP: " + json .dumps (msg ))
788
793
return rs_handlers .not_found (msg )
789
- start_year = 2018
790
- end_year = 2022
791
- endpoint_response = generate_title_ii_summary_response (program_id , start_year , end_year )
794
+
795
+ endpoint_response = generate_title_ii_summary_response (program_id , TITLE_II_START_YEAR , TITLE_II_END_YEAR )
792
796
return endpoint_response
793
797
794
798
# /pdl/titles/title-ii/proposals/2024/house/eqip/predicted
@@ -1549,6 +1553,7 @@ def generate_title_i_total_summary_response(title_id, start_year, end_year):
1549
1553
1550
1554
return final_summary
1551
1555
1556
+
1552
1557
def generate_title_ii_total_summary_response (title_id , start_year , end_year ):
1553
1558
session = Session ()
1554
1559
@@ -1600,6 +1605,8 @@ def generate_title_ii_total_summary_response(title_id, start_year, end_year):
1600
1605
title_entry = {
1601
1606
'titleName' : title_name ,
1602
1607
'totalPaymentInDollars' : title_total_payment ,
1608
+ 'startYear' : start_year ,
1609
+ 'endYear' : end_year ,
1603
1610
'programs' : program_list
1604
1611
}
1605
1612
@@ -3127,7 +3134,7 @@ def generate_title_ii_summary_response(program_id, start_year, end_year):
3127
3134
# Sort the sub programs by total payment in descending order
3128
3135
sub_programs_list = sorted (sub_programs_list , key = lambda x : x ['totalPaymentInDollars' ], reverse = True )
3129
3136
3130
- response = {** total_values_dict , "statutes" : statutes_list , "subPrograms" : sub_programs_list }
3137
+ response = {"startYear" : start_year , "endYear" : end_year , ** total_values_dict , "statutes" : statutes_list , "subPrograms" : sub_programs_list }
3131
3138
return response
3132
3139
3133
3140
0 commit comments