fixing the 'KeyError' when using an empty times dataframe. Returning 'green'
This commit is contained in:
parent
c36e913472
commit
8027620f22
@ -218,8 +218,6 @@ class SQLHandler():
|
||||
|
||||
def get_times_of_shipcall(self, shipcall)->pd.DataFrame:
|
||||
df_times = self.df_dict.get('times') # -> pd.DataFrame
|
||||
if df_times is None:
|
||||
return None
|
||||
df_times = df_times.loc[df_times["shipcall_id"]==shipcall.id]
|
||||
return df_times
|
||||
|
||||
|
||||
@ -31,6 +31,9 @@ class ValidationRules(ValidationRuleFunctions):
|
||||
# prepare df_times, which every validation rule tends to use
|
||||
df_times = self.sql_handler.df_dict.get('times') # -> pd.DataFrame
|
||||
|
||||
if len(df_times)==0:
|
||||
return (StatusFlags.GREEN.value, [])
|
||||
|
||||
# filter by shipcall id
|
||||
df_times = self.sql_handler.get_times_of_shipcall(shipcall)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user