29 lines
589 B
Go
Raw Normal View History

2024-07-28 19:59:50 +01:00
package handlers_packages
import (
2024-07-29 22:49:20 +01:00
"brunel/buildqueue"
2024-07-29 16:39:11 +01:00
"brunel/domain"
2024-07-28 19:59:50 +01:00
"brunel/packages"
2024-07-29 16:39:11 +01:00
"time"
2024-07-28 19:59:50 +01:00
"github.com/gofiber/fiber/v2"
)
2024-07-29 16:39:11 +01:00
type CountsResponse struct {
LastUpdateTime time.Time `json:"lastUpdateTime"`
Counts domain.PackagesCount `json:"counts"`
}
2024-07-28 19:59:50 +01:00
func Counts(c *fiber.Ctx) error {
2024-07-29 22:49:20 +01:00
cts := packages.GetPackagesCount()
bcts := buildqueue.GetCounts()
cts.Building = bcts.Building
cts.Queued = bcts.Queued
2024-07-29 16:39:11 +01:00
response := CountsResponse{
LastUpdateTime: packages.LastUpdateTime,
2024-07-29 22:49:20 +01:00
Counts: cts,
2024-07-29 16:39:11 +01:00
}
return c.Status(fiber.StatusOK).JSON(response)
2024-07-28 19:59:50 +01:00
}