diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2025-08-18 13:58:45 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2025-08-18 20:34:32 +0000 |
| commit | 52052143baa2172d2be0fbcc38cba0fe70b16f82 (patch) | |
| tree | c8f8e40316ea674964beb78769060e6e8bb27e5f /syz-cluster/pkg | |
| parent | 1804e95e3ff848c11e87e8efe7560f03c011c081 (diff) | |
syz-cluster: fix stats display for non finished sessions
We could not generate the stats page when there were findings for a not
yet finished session.
Fix it and adjust the tests.
Diffstat (limited to 'syz-cluster/pkg')
| -rw-r--r-- | syz-cluster/pkg/db/stats_repo.go | 2 | ||||
| -rw-r--r-- | syz-cluster/pkg/db/stats_repo_test.go | 29 |
2 files changed, 19 insertions, 12 deletions
diff --git a/syz-cluster/pkg/db/stats_repo.go b/syz-cluster/pkg/db/stats_repo.go index fa6c1d901..d881cb243 100644 --- a/syz-cluster/pkg/db/stats_repo.go +++ b/syz-cluster/pkg/db/stats_repo.go @@ -46,7 +46,7 @@ func (repo *StatsRepository) FindingsPerWeek(ctx context.Context) ( TIMESTAMP_TRUNC(Sessions.FinishedAt, WEEK) as Date, COUNT(*) as Count FROM Findings -JOIN Sessions ON Sessions.ID = Findings.SessionID +JOIN Sessions ON Sessions.ID = Findings.SessionID AND Sessions.FinishedAt IS NOT NULL GROUP BY Date ORDER BY Date`, }) diff --git a/syz-cluster/pkg/db/stats_repo_test.go b/syz-cluster/pkg/db/stats_repo_test.go index 637894edf..ce2b05ca9 100644 --- a/syz-cluster/pkg/db/stats_repo_test.go +++ b/syz-cluster/pkg/db/stats_repo_test.go @@ -15,19 +15,26 @@ func TestStatsSQLs(t *testing.T) { // That already brings a lot of value. client, ctx := NewTransientDB(t) - // Add some data to test field decoding as well. + checkStats := func() { + statsRepo := NewStatsRepository(client) + _, err := statsRepo.ProcessedSeriesPerWeek(ctx) + assert.NoError(t, err) + _, err = statsRepo.FindingsPerWeek(ctx) + assert.NoError(t, err) + _, err = statsRepo.SessionStatusPerWeek(ctx) + assert.NoError(t, err) + _, err = statsRepo.DelayPerWeek(ctx) + assert.NoError(t, err) + } + dtd := &dummyTestData{t, ctx, client} session := dtd.dummySession(dtd.dummySeries()) + checkStats() dtd.startSession(session) + dtd.addSessionTest(session, "test") + checkStats() + dtd.addFinding(session, "test", "test") + checkStats() dtd.finishSession(session) - - statsRepo := NewStatsRepository(client) - _, err := statsRepo.ProcessedSeriesPerWeek(ctx) - assert.NoError(t, err) - _, err = statsRepo.FindingsPerWeek(ctx) - assert.NoError(t, err) - _, err = statsRepo.SessionStatusPerWeek(ctx) - assert.NoError(t, err) - _, err = statsRepo.DelayPerWeek(ctx) - assert.NoError(t, err) + checkStats() } |
