brunel/handlers/packages/counts.go

29 lines
589 B
Go
Raw Normal View History

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