2626)
2727from elementary .monitor .api .totals_schema import TotalsSchema
2828from elementary .monitor .data_monitoring .schema import SelectorFilterSchema
29+ from elementary .monitor .fetchers .invocations .schema import DbtInvocationSchema
2930from elementary .monitor .fetchers .tests .schema import (
3031 NormalizedTestSchema ,
3132 TestDBRowSchema ,
@@ -69,6 +70,7 @@ def _get_test_results_db_rows(
6970 def get_test_results_summary (
7071 self ,
7172 filter : SelectorFilterSchema = SelectorFilterSchema (),
73+ dbt_invocation : Optional [DbtInvocationSchema ] = None ,
7274 ) -> List [TestResultSummarySchema ]:
7375 filtered_test_results_db_rows = self .test_results_db_rows
7476 if filter .tag :
@@ -93,11 +95,19 @@ def get_test_results_summary(
9395 )
9496 ]
9597
96- filtered_test_results_db_rows = [
97- test_result
98- for test_result in filtered_test_results_db_rows
99- if test_result .invocations_rank_index == 1
100- ]
98+ if dbt_invocation and dbt_invocation .invocation_id :
99+ filtered_test_results_db_rows = [
100+ test_result
101+ for test_result in filtered_test_results_db_rows
102+ if test_result .invocation_id == dbt_invocation .invocation_id
103+ ]
104+ else :
105+ filtered_test_results_db_rows = [
106+ test_result
107+ for test_result in filtered_test_results_db_rows
108+ if test_result .invocations_rank_index == 1
109+ ]
110+
101111 return [
102112 TestResultSummarySchema (
103113 test_unique_id = test_result .test_unique_id ,
0 commit comments