Skip to content

Commit

Permalink
Exclude profiles with labels from history.
Browse files Browse the repository at this point in the history
History list showed evaluation results even for profiles having
labels. This is different from the behaviour of Profile list and
status, which only showed results for profiles without labels.

This change makes the behaviour of History list uniform with Profile
list and status.

Fixes stacklok/minder-stories#102
  • Loading branch information
blkt committed Nov 7, 2024
1 parent 67bd38d commit 8adedfc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions database/query/eval_history.sql
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ SELECT s.id::uuid AS evaluation_id,
AND (sqlc.narg(tots)::timestamp without time zone IS NULL OR s.evaluation_time < sqlc.narg(tots))
-- implicit filter by project id
AND j.id = sqlc.arg(projectId)
-- implicit filter, exclude all labelled profiles
AND p.labels = ARRAY[]::TEXT[]
ORDER BY
CASE WHEN sqlc.narg(next)::timestamp without time zone IS NULL THEN s.evaluation_time END ASC,
CASE WHEN sqlc.narg(prev)::timestamp without time zone IS NULL THEN s.evaluation_time END DESC
Expand Down
2 changes: 2 additions & 0 deletions internal/db/eval_history.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions internal/db/eval_history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ func TestListEvaluationHistoryFilters(t *testing.T) {
ere1 := createRandomEvaluationRuleEntity(t, riID1, repo1.ID)
es1 := createRandomEvaluationStatus(t, ere1)

// Evaluations for this profile should not show up in the
// results.
ruleType2 := createRandomRuleType(t, proj.ID)
profile2 := createRandomProfile(t, proj.ID, []string{"labelled"})
riID2 := createRandomRuleInstance(
t,
proj.ID,
profile2.ID,
ruleType2.ID,
)
ere2 := createRandomEvaluationRuleEntity(t, riID2, repo1.ID)
createRandomEvaluationStatus(t, ere2)

tests := []struct {
name string
params ListEvaluationHistoryParams
Expand Down Expand Up @@ -671,6 +684,7 @@ func TestGetEvaluationHistory(t *testing.T) {
for i := 0; i < 10; i++ {
repos = append(repos, createRandomRepository(t, proj.ID, prov))
}

ruleType1 := createRandomRuleType(t, proj.ID)
profile1 := createRandomProfile(t, proj.ID, []string{})
riID1 := createRandomRuleInstance(
Expand Down

0 comments on commit 8adedfc

Please sign in to comment.