Skip to content

Commit

Permalink
all: imp docs
Browse files Browse the repository at this point in the history
  • Loading branch information
schzhn committed Feb 27, 2023
1 parent 8fb7e73 commit d7db0a5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions internal/querylog/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"net"
"net/http"
"net/url"
"sort"
"strconv"
"strings"
"time"
Expand All @@ -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"
)

Expand Down Expand Up @@ -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()),
Expand Down
10 changes: 5 additions & 5 deletions internal/stats/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ package stats
import (
"encoding/json"
"net/http"
"sort"
"time"

"github.com/AdguardTeam/AdGuardHome/internal/aghalg"
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
"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.
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions internal/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit d7db0a5

Please sign in to comment.