@@ -76,19 +76,33 @@ def update_historical_data(logger):
7676 update (data ,logger )
7777 logger .info ("Finished updating historic data" )
7878
79- def patch_20242025_season (logger ):
80- logger .info ("Patching in data from the 2024-2025 season" )
79+ def patch_seasons (season_start_years ,logger ):
80+ season_end_years = [y + 1 for y in season_start_years ]
81+ logger .info ("Starting to Patch in Seasons" )
82+ for start , end in zip (season_start_years , season_end_years ):
83+ logger .info (f"Patching in data from the { start } -{ end } season" )
8184
82- # TODO: Add csv to directory
83- data = pd .read_csv ("respiratory_detections.csv" )
84-
85- # current dashboard only needs one table
86- new_data = expand_detections_columns (data )
87- new_data = duplicate_provincial_detections (new_data )
88-
89- #update database
90- update (new_data ,logger )
91- logger .info ("Finished patching in 2024-2025 season" )
85+ if start >= 2024 :
86+ data = pd .read_csv (f"{ start } _{ end } _respiratory_detections.csv" )
87+
88+ # current dashboard only needs one table
89+ new_data = expand_detections_columns (data )
90+ new_data = duplicate_provincial_detections (new_data )
91+
92+ #update database
93+ update (new_data ,logger )
94+ else :
95+ resp_data = pd .read_csv (f"{ start } _{ end } _respiratory_detections.csv" )
96+ pos_data = pd .read_csv (f"{ start } _{ end } _positive_tests.csv" )
97+ data_dict = {"positive" :pos_data ,"respiratory_detection" :resp_data }
98+
99+ # Combine all rables into a single table
100+ data = combine_tables (data_dict )
101+
102+ #update database
103+ update (data ,logger )
104+ logger .info ("Finished patching in {season[0]}-{season[1]} season" )
105+ logger .info ("Finished Patching in Seasons" )
92106
93107def main ():
94108 # args and usage
@@ -110,7 +124,7 @@ def main():
110124 "--patch" ,
111125 "-pat" ,
112126 action = "store_true" ,
113- help = "patch in the 2024-2025 season , which is unarchived and must be obtained through a csv "
127+ help = "patch in missings seasons , which are unarchived and must be obtained through csvs "
114128 # TODO: Look into passing a file name
115129 )
116130 # fmt: on
@@ -141,7 +155,7 @@ def main():
141155 if historical_flag :
142156 update_historical_data (logger )
143157 if patch_flag :
144- patch_20242025_season ( logger )
158+ patch_seasons ( season_start_years = [ 2013 , 2014 , 2024 ], logger = logger )
145159
146160
147161if __name__ == "__main__" :
0 commit comments