Standardize neon cyan on #00e8f5, wire SacredPageHeader across Builds/Path Tracer/LOTL, dedupe Pages.css, align Path Tracer chrome, drop dead wealth-deck CSS, add prefers-color-scheme shell + HelpTip, sidebar version from package.json build inject, and Vitest CSS regression guards.
36 lines
831 B
Go
36 lines
831 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"crypto-miner-server/internal/db"
|
|
)
|
|
|
|
const (
|
|
dashboardInitDefaultLimit = 100
|
|
dashboardInitMaxLimit = 2000
|
|
)
|
|
|
|
// parseDashboardInitFilter reads optional init_limit / init_offset on /ws/dashboard.
|
|
func parseDashboardInitFilter(r *http.Request) (db.AgentListFilter, bool) {
|
|
limitStr := r.URL.Query().Get("init_limit")
|
|
if limitStr == "" {
|
|
return db.AgentListFilter{}, false
|
|
}
|
|
limit, err := strconv.Atoi(limitStr)
|
|
if err != nil || limit <= 0 {
|
|
limit = dashboardInitDefaultLimit
|
|
}
|
|
if limit > dashboardInitMaxLimit {
|
|
limit = dashboardInitMaxLimit
|
|
}
|
|
offset := 0
|
|
if offStr := r.URL.Query().Get("init_offset"); offStr != "" {
|
|
if o, err := strconv.Atoi(offStr); err == nil && o >= 0 {
|
|
offset = o
|
|
}
|
|
}
|
|
return db.AgentListFilter{Limit: limit, Offset: offset}, true
|
|
}
|