add last_mirror_ts to general stats
This commit is contained in:
26
api.go
26
api.go
@@ -5,6 +5,7 @@ import (
|
|||||||
"github.com/go-chi/render"
|
"github.com/go-chi/render"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"somegit.dev/ALHP/ALHP.GO/ent"
|
"somegit.dev/ALHP/ALHP.GO/ent"
|
||||||
"somegit.dev/ALHP/ALHP.GO/ent/dbpackage"
|
"somegit.dev/ALHP/ALHP.GO/ent/dbpackage"
|
||||||
"somegit.dev/ALHP/ALHP.GO/ent/predicate"
|
"somegit.dev/ALHP/ALHP.GO/ent/predicate"
|
||||||
@@ -14,11 +15,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type StatsResponse struct {
|
type StatsResponse struct {
|
||||||
Failed int `json:"failed"`
|
Failed int `json:"failed"`
|
||||||
Skipped int `json:"skipped"`
|
Skipped int `json:"skipped"`
|
||||||
Latest int `json:"latest"`
|
Latest int `json:"latest"`
|
||||||
Queued int `json:"queued"`
|
Queued int `json:"queued"`
|
||||||
LTO *struct {
|
LastMirrorTimestamp *int64 `json:"last_mirror_timestamp,omitempty"`
|
||||||
|
LTO *struct {
|
||||||
Enabled int `json:"enabled"`
|
Enabled int `json:"enabled"`
|
||||||
Disabled int `json:"disabled"`
|
Disabled int `json:"disabled"`
|
||||||
Unknown int `json:"unknown"`
|
Unknown int `json:"unknown"`
|
||||||
@@ -93,6 +95,20 @@ func GetStats(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if os.Getenv("ALHP_TIMESTAMP_PATH") != "" {
|
||||||
|
tsFile, err := os.ReadFile(os.Getenv("ALHP_TIMESTAMP_PATH"))
|
||||||
|
if err != nil {
|
||||||
|
log.Warningf("error reading timestamp file: %v", err)
|
||||||
|
} else {
|
||||||
|
ts, err := strconv.ParseInt(string(tsFile), 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
log.Warningf("error parsing timestamp file: %v", err)
|
||||||
|
} else {
|
||||||
|
resp.LastMirrorTimestamp = &ts
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render.Status(r, http.StatusOK)
|
render.Status(r, http.StatusOK)
|
||||||
render.JSON(w, r, resp)
|
render.JSON(w, r, resp)
|
||||||
}
|
}
|
||||||
|
@@ -224,6 +224,11 @@ components:
|
|||||||
format: int64
|
format: int64
|
||||||
description: Number of packages currently in the build queue
|
description: Number of packages currently in the build queue
|
||||||
example: 5
|
example: 5
|
||||||
|
last_mirror_timestamp:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
description: Latest mirror timestamp to detect outdated mirrors (Unix timestamp)
|
||||||
|
example: 1702612991
|
||||||
lto:
|
lto:
|
||||||
type: object
|
type: object
|
||||||
description: LTO status summary across all packages
|
description: LTO status summary across all packages
|
||||||
|
Reference in New Issue
Block a user