Merge branch 'main' into feat/network-probes

Resolved conflict in internal/records/records.go:
- Upstream refactor moved deletion code to records_deletion.go and
  switched averaging functions from package-level globals to local
  variables (var row StatsRecord / params := make(dbx.Params, 1)).
- Kept AverageProbeStats and rewrote it to match the new local-variable
  pattern.
- Dropped duplicated deletion helpers from records.go (they now live in
  records_deletion.go).
- Added "network_probe_stats" to the collections list in
  records_deletion.go:deleteOldSystemStats so probe stats keep the same
  retention policy.
This commit is contained in:
xiaomiku01
2026-04-17 13:49:18 +08:00
20 changed files with 1688 additions and 782 deletions

View File

@@ -8,7 +8,6 @@ import (
"hash/fnv"
"math/rand"
"net"
"slices"
"strings"
"sync/atomic"
"time"
@@ -368,12 +367,16 @@ func (sys *System) HasUser(app core.App, user *core.Record) bool {
if v, _ := utils.GetEnv("SHARE_ALL_SYSTEMS"); v == "true" {
return true
}
record, err := sys.getRecord(app)
if err != nil {
var recordData = struct {
Users string
}{}
err := app.DB().NewQuery("SELECT users FROM systems WHERE id={:id}").
Bind(dbx.Params{"id": sys.Id}).
One(&recordData)
if err != nil || recordData.Users == "" {
return false
}
users := record.GetStringSlice("users")
return slices.Contains(users, user.Id)
return strings.Contains(recordData.Users, user.Id)
}
// setDown marks a system as down in the database.