@@ -74,27 +74,23 @@ def archive_as_successful(path_src, filename, source):
74
74
75
75
(source , signal , time_type , geo_type , time_value , issue , lag ) = details
76
76
77
- is_wip = False
78
- if signal [:4 ].lower () == "wip_" :
79
- is_wip = True
80
- print (signal , is_wip )
77
+ is_wip = signal [:4 ].lower () == "wip_"
81
78
82
79
csv_rows = csv_importer_impl .load_csv (path , geo_type )
83
80
84
- all_rows_valid = False
85
- try :
86
- cc_rows = CovidcastRow .fromCsvRows (csv_rows , source , signal , time_type , geo_type , time_value , issue , lag , is_wip )
87
- rows_list = list (cc_rows )
88
- if not rows_list :
89
- raise ValueError ("No data" )
90
- result = database .insert_or_update_bulk (rows_list )
91
- if result is None or result : # else would indicate zero rows inserted
92
- database .commit ()
93
- all_rows_valid = True
94
- except Exception as e :
95
- all_rows_valid = False
96
- print ('exception while inserting rows:' , e )
97
- database .rollback ()
81
+ cc_rows = CovidcastRow .fromCsvRows (csv_rows , source , signal , time_type , geo_type , time_value , issue , lag , is_wip )
82
+ rows_list = list (cc_rows )
83
+ all_rows_valid = rows_list and all (r is not None for r in rows_list )
84
+ if all_rows_valid :
85
+ try :
86
+ result = database .insert_or_update_bulk (rows_list )
87
+ print (f"insert_or_update_bulk { filename } returned { result } " )
88
+ if result is None or result : # else would indicate zero rows inserted
89
+ database .commit ()
90
+ except Exception as e :
91
+ all_rows_valid = False
92
+ print ('exception while inserting rows:' , e )
93
+ database .rollback ()
98
94
99
95
# archive the current file based on validation results
100
96
if all_rows_valid :
0 commit comments