@@ -361,17 +361,22 @@ def recalculate_scores_history(self) -> None:
361361 )
362362 overall_scores = get_current_session ().execute (query ).mappings ().all ()
363363 current_history : dict [tuple [datetime , str , str ], ScoreDefinitionResultHistoryEntry ] = {}
364- for entry in self .history :
365- current_history [(entry .last_run_time , entry .category ,)] = entry
366-
367364 renewed_history : dict [tuple [datetime , str , str ], float ] = {}
365+
368366 for scores in overall_scores :
369367 renewed_history [(scores ["last_run_time" ], "score" ,)] = scores ["score" ]
370368 renewed_history [(scores ["last_run_time" ], "cde_score" ,)] = scores ["cde_score" ]
371369
370+ for entry in self .history :
371+ entry_key = (entry .last_run_time , entry .category ,)
372+ if entry_key in renewed_history :
373+ current_history [entry_key ] = entry
374+
372375 for key , entry in current_history .items ():
373376 entry .score = renewed_history [key ]
374377
378+ self .history = list (current_history .values ())
379+
375380 def _get_raw_query_filters (self , cde_only : bool = False , prefix : str | None = None ) -> list [str ]:
376381 values_by_field = defaultdict (list )
377382 for filter_ in self .filters :
0 commit comments