Skip to content

Commit 5ed0ed3

Browse files
committed
Fix bug in selection of representative group result
Signed-off-by: Matthias Büchse <matthias.buechse@alasca.cloud>
1 parent aad3700 commit 5ed0ed3

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

compliance-monitor/monitor.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,15 @@ def pick_filter(ctx, results, scopeuuid, *subjects):
833833
return [r for r in rs if r is not None]
834834

835835

836+
NIL = object() # the version in question does not have a result
837+
# used to sort multiple versions according to the "goodness" of their result
838+
RESULT_SCORE = {
839+
-1: 0,
840+
None: 1,
841+
NIL: 2, # NIL and None are basically the same, but prefer None because it has more info
842+
0: 3,
843+
1: 4,
844+
}
836845
COLOR_MAP = {
837846
-1: '🛑', # fail
838847
None: '🟧', # missing
@@ -847,11 +856,10 @@ def summary_filter(scope_results):
847856
if not isinstance(scope_results, dict):
848857
# new generalized case: "aggregate" results for multiple subjects
849858
# simplified computation: just select the worst subject to represent the group
850-
scope_results = [sr for sr in scope_results if sr.get('best_passed') is not None]
851859
scope_results = min(
852860
scope_results,
853861
default={},
854-
key=lambda sr: -sr['best_passed'],
862+
key=lambda sr: RESULT_SCORE[sr.get('result', NIL)],
855863
)
856864
if not scope_results:
857865
return '🛑 –'

0 commit comments

Comments
 (0)