fixing the 'KeyError' when using an empty times dataframe. Returning 'green'

This commit is contained in:
scopesorting 2023-11-28 14:17:07 +01:00 committed by Daniel Schick
parent c36e913472
commit 8027620f22
2 changed files with 3 additions and 2 deletions

View File

@ -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

View File

@ -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)