fixes pihole stats

This commit is contained in:
2026-10-04 17:52:40 +02:00
parent 961d6d76c4
commit c61ed85a01
2 changed files with 7 additions and 6 deletions
+6 -5
View File
@@ -17,7 +17,7 @@ type Queries struct {
UniqueDomains int64 `json:"unique_domains"` UniqueDomains int64 `json:"unique_domains"`
Forwarded int64 `json:"forwarded"` Forwarded int64 `json:"forwarded"`
Cached int64 `json:"cached"` Cached int64 `json:"cached"`
Frequency int64 `json:"frequency"` Frequency float64 `json:"frequency"`
} }
type Clients struct { type Clients struct {
@@ -31,11 +31,12 @@ type Gravity struct {
} }
func (ph *PiHConnector) Summary() Summary { func (ph *PiHConnector) Summary() Summary {
summary := &Summary{} summary := Summary{}
err := json.Unmarshal(ph.get("stats/summary"), summary) response := ph.get("stats/summary")
err := json.Unmarshal(response, &summary)
if err != nil { if err != nil {
summary = &Summary{} summary = Summary{}
} }
return *summary return summary
} }
+1 -1
View File
@@ -48,7 +48,7 @@ func createPiholeStats(ctx context.Context, _ terminalapi.Terminal, _ interface{
if err := list.Write(fmt.Sprintf("Cached Queries: %d\n", summary.Queries.Cached), text.WriteCellOpts(cell.FgColor(cell.ColorWhite))); err != nil { if err := list.Write(fmt.Sprintf("Cached Queries: %d\n", summary.Queries.Cached), text.WriteCellOpts(cell.FgColor(cell.ColorWhite))); err != nil {
return err return err
} }
if err := list.Write(fmt.Sprintf("Queries per Second: %d\n", summary.Queries.Frequency), text.WriteCellOpts(cell.FgColor(cell.ColorWhite))); err != nil { if err := list.Write(fmt.Sprintf("Queries per Second: %f\n", summary.Queries.Frequency), text.WriteCellOpts(cell.FgColor(cell.ColorWhite))); err != nil {
return err return err
} }
return nil return nil