31 lines
689 B
Go
31 lines
689 B
Go
package handlers_build
|
|
|
|
import (
|
|
"brunel/buildqueue"
|
|
"brunel/domain"
|
|
"brunel/helpers"
|
|
"brunel/packages"
|
|
"time"
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
type BuildQueueCountResponse struct {
|
|
LastUpdateTime time.Time `json:"lastUpdateTime"`
|
|
Counts domain.BuildQueueCount `json:"counts"`
|
|
}
|
|
|
|
func Counts(c *fiber.Ctx) error {
|
|
if cachedResponse, ok := helpers.Cache.Get("buildcounts"); ok {
|
|
return c.Status(fiber.StatusOK).JSON(cachedResponse)
|
|
}
|
|
|
|
response := BuildQueueCountResponse{
|
|
LastUpdateTime: packages.LastUpdateTime,
|
|
Counts: buildqueue.GetCounts(),
|
|
}
|
|
|
|
helpers.Cache.Set("buildcounts", response)
|
|
return c.Status(fiber.StatusOK).JSON(response)
|
|
}
|