all: imp docs
This commit is contained in:
parent
8fb7e7349d
commit
d7db0a5af1
|
@ -7,7 +7,6 @@ import (
|
|||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -18,6 +17,7 @@ import (
|
|||
"github.com/AdguardTeam/golibs/log"
|
||||
"github.com/AdguardTeam/golibs/stringutil"
|
||||
"github.com/AdguardTeam/golibs/timeutil"
|
||||
"golang.org/x/exp/slices"
|
||||
"golang.org/x/net/idna"
|
||||
)
|
||||
|
||||
|
@ -127,7 +127,7 @@ func (l *queryLog) handleGetQueryLogConfig(w http.ResponseWriter, r *http.Reques
|
|||
defer l.lock.Unlock()
|
||||
|
||||
ignored := l.conf.Ignored.Values()
|
||||
sort.Strings(ignored)
|
||||
slices.Sort(ignored)
|
||||
_ = aghhttp.WriteJSONResponse(w, r, getConfigResp{
|
||||
Enabled: aghalg.BoolToNullBool(l.conf.Enabled),
|
||||
Interval: float64(l.conf.RotationIvl.Milliseconds()),
|
||||
|
|
|
@ -5,7 +5,6 @@ package stats
|
|||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/aghalg"
|
||||
|
@ -13,6 +12,7 @@ import (
|
|||
"github.com/AdguardTeam/AdGuardHome/internal/aghnet"
|
||||
"github.com/AdguardTeam/golibs/log"
|
||||
"github.com/AdguardTeam/golibs/timeutil"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
// topAddrs is an alias for the types of the TopFoo fields of statsResponse.
|
||||
|
@ -103,14 +103,14 @@ func (s *StatsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) {
|
|||
_ = aghhttp.WriteJSONResponse(w, r, resp)
|
||||
}
|
||||
|
||||
// handleGetStatsConfig handles requests to the GET /control/stats_info
|
||||
// handleGetStatsConfig handles requests to the GET /control/stats/config
|
||||
// endpoint.
|
||||
func (s *StatsCtx) handleGetStatsConfig(w http.ResponseWriter, r *http.Request) {
|
||||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
|
||||
ignored := s.ignored.Values()
|
||||
sort.Strings(ignored)
|
||||
slices.Sort(ignored)
|
||||
|
||||
resp := getConfigResp{
|
||||
Enabled: aghalg.BoolToNullBool(s.enabled),
|
||||
|
@ -150,8 +150,8 @@ func (s *StatsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) {
|
|||
s.setLimitLocked(int(reqData.IntervalDays))
|
||||
}
|
||||
|
||||
// handlePutStatsConfig handles requests to the PUT /control/stats_config
|
||||
// endpoint.
|
||||
// handlePutStatsConfig handles requests to the PUT
|
||||
// /control/stats/config/update endpoint.
|
||||
func (s *StatsCtx) handlePutStatsConfig(w http.ResponseWriter, r *http.Request) {
|
||||
reqData := getConfigResp{}
|
||||
err := json.NewDecoder(r.Body).Decode(&reqData)
|
||||
|
|
|
@ -43,8 +43,7 @@ type Config struct {
|
|||
// Filename is the name of the database file.
|
||||
Filename string
|
||||
|
||||
// Limit is an upper limit for collecting statistics into the
|
||||
// current unit.
|
||||
// Limit is an upper limit for collecting statistics.
|
||||
Limit time.Duration
|
||||
|
||||
// Enabled tells if the statistics are enabled.
|
||||
|
@ -537,6 +536,7 @@ func (s *StatsCtx) loadUnits(limit uint32) (units []*unitDB, firstID uint32) {
|
|||
// Per-hour units.
|
||||
units = make([]*unitDB, 0, limit)
|
||||
firstID = curID - limit + 1
|
||||
|
||||
for i := firstID; i != curID; i++ {
|
||||
u := loadUnitFromDB(tx, i)
|
||||
if u == nil {
|
||||
|
|
Loading…
Reference in New Issue