feat(panel): reskin backend — node sortIndex, presence/speed, /api/system, credentials, subscription aggregation (Node+Go parity)
This commit is contained in:
@@ -272,6 +272,10 @@ func (a *App) housekeeping() {
|
||||
return
|
||||
}
|
||||
a.getSessions().Prune()
|
||||
// System-status sampling + due external-source refreshes (outside the
|
||||
// transaction; fetches must not hold the store lock).
|
||||
a.monitor().Sample(a.store.Snapshot(), false)
|
||||
a.RefreshDueSources()
|
||||
}
|
||||
|
||||
// ---------- main ----------
|
||||
@@ -361,6 +365,32 @@ func run() error {
|
||||
}
|
||||
}
|
||||
|
||||
// Node sort order migration (idempotent): unless the stored
|
||||
// sortIndex values are exactly the permutation 0..n-1, renumber by
|
||||
// storage order. Mirrors the Node implementation's boot migration.
|
||||
{
|
||||
nodes := store.Snapshot().Nodes
|
||||
seen := map[int]bool{}
|
||||
valid := true
|
||||
for _, node := range nodes {
|
||||
if node.SortIndex < 0 || node.SortIndex >= len(nodes) || seen[node.SortIndex] {
|
||||
valid = false
|
||||
break
|
||||
}
|
||||
seen[node.SortIndex] = true
|
||||
}
|
||||
if !valid {
|
||||
if _, err := store.Transaction(func(d *Data) (any, error) {
|
||||
for index, node := range d.Nodes {
|
||||
node.SortIndex = index
|
||||
}
|
||||
return nil, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
app := NewApp(store, nil, NewOrchestrator(store))
|
||||
app.replaceSessions(NewSessionManager(app.sessionHours()))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user