added users section in stats

This commit is contained in:
2025-11-20 18:15:54 +01:00
parent 97ccd7bfbf
commit 5caa4d3e5d
2 changed files with 31 additions and 1 deletions

View File

@@ -200,6 +200,7 @@ type StatsResponse struct {
FQDNs int `json:"fqdns"`
CSRs int `json:"csrs"`
Certificates int `json:"certificates"`
Users int `json:"users"`
}
type Space struct {
@@ -655,7 +656,7 @@ func getStatsHandler(w http.ResponseWriter, r *http.Request) {
return
}
var spacesCount, fqdnsCount, csrsCount, certificatesCount int
var spacesCount, fqdnsCount, csrsCount, certificatesCount, usersCount int
// Zähle Spaces
err := db.QueryRow("SELECT COUNT(*) FROM spaces").Scan(&spacesCount)
@@ -689,11 +690,20 @@ func getStatsHandler(w http.ResponseWriter, r *http.Request) {
return
}
// Zähle Benutzer
err = db.QueryRow("SELECT COUNT(*) FROM users").Scan(&usersCount)
if err != nil {
http.Error(w, "Fehler beim Abrufen der Statistiken", http.StatusInternalServerError)
log.Printf("Fehler beim Zählen der Benutzer: %v", err)
return
}
response := StatsResponse{
Spaces: spacesCount,
FQDNs: fqdnsCount,
CSRs: csrsCount,
Certificates: certificatesCount,
Users: usersCount,
}
json.NewEncoder(w).Encode(response)
@@ -2211,6 +2221,12 @@ components:
csrs:
type: integer
example: 7
certificates:
type: integer
example: 8
users:
type: integer
example: 3
Space:
type: object
properties: