brunel/handlers/packages/counts.go
2024-07-29 22:49:20 +01:00

29 lines
589 B
Go

package handlers_packages
import (
"brunel/buildqueue"
"brunel/domain"
"brunel/packages"
"time"
"github.com/gofiber/fiber/v2"
)
type CountsResponse struct {
LastUpdateTime time.Time `json:"lastUpdateTime"`
Counts domain.PackagesCount `json:"counts"`
}
func Counts(c *fiber.Ctx) error {
cts := packages.GetPackagesCount()
bcts := buildqueue.GetCounts()
cts.Building = bcts.Building
cts.Queued = bcts.Queued
response := CountsResponse{
LastUpdateTime: packages.LastUpdateTime,
Counts: cts,
}
return c.Status(fiber.StatusOK).JSON(response)
}