diff options
| author | Shulhan <ms@kilabit.info> | 2025-08-01 02:21:20 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2025-08-01 02:21:20 +0700 |
| commit | 5338799c9fa5158031ebae53c6e64254175e7412 (patch) | |
| tree | 83ffde1d8bf34e4323c384f0877dfd21090a0ef3 /reports.go | |
| parent | 5a90a6822fc0d6a0d0d07b4b4583f9dbc20ba0e6 (diff) | |
| download | lilin-5338799c9fa5158031ebae53c6e64254175e7412.tar.xz | |
all: record and display the history of failed scan
In the main Reports struct, we record the failed ScanReport in separate
slices.
Those slices then displayed on the main page under "Fail history"
section.
Diffstat (limited to 'reports.go')
| -rw-r--r-- | reports.go | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -3,8 +3,31 @@ package lilin +import "sync" + +const failKeepSize = 600 +const failMax = failKeepSize + (failKeepSize / 3) + // Reports contains the report for all services. type Reports struct { Services map[string]*ServiceReport Title string + Fail []ScanReport + sync.Mutex +} + +// Store the service scan report. +func (reports *Reports) Store(scanReport ScanReport) { + reports.Lock() + var svcReport = reports.Services[scanReport.Name] + svcReport.Store(scanReport) + if !scanReport.Success { + reports.Fail = append(reports.Fail, scanReport) + if len(reports.Fail) >= failMax { + var start = len(reports.Fail) - failKeepSize + copy(reports.Fail, reports.Fail[start:]) + reports.Fail = reports.Fail[:failKeepSize-1] + } + } + reports.Unlock() } |
