diff --git a/handlers/build/count.go b/handlers/build/count.go deleted file mode 100644 index 2df7741..0000000 --- a/handlers/build/count.go +++ /dev/null @@ -1,30 +0,0 @@ -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) -} diff --git a/handlers/build/queue.go b/handlers/build/queue.go index 902089d..fd23026 100644 --- a/handlers/build/queue.go +++ b/handlers/build/queue.go @@ -4,8 +4,6 @@ import ( "brunel/buildqueue" "brunel/domain" "brunel/fastmap" - "brunel/helpers" - "fmt" "strings" "github.com/gofiber/fiber/v2" @@ -22,11 +20,6 @@ func Queue(c *fiber.Ctx) error { search := strings.ToLower(c.Query("search")) filter := c.Query("filter") - cacheKey := fmt.Sprintf("buildqueue:%d:%d:%s:%s", pageNum, pageSize, search, filter) - if cachedResponse, ok := helpers.Cache.Get(cacheKey); ok { - return c.Status(fiber.StatusOK).JSON(cachedResponse) - } - // Adjust pageNum to be 0-based for GetPage adjustedPageNum := pageNum - 1 if adjustedPageNum < 0 { @@ -60,6 +53,5 @@ func Queue(c *fiber.Ctx) error { Packages: result, } - helpers.Cache.Set(cacheKey, response) return c.Status(fiber.StatusOK).JSON(response) } diff --git a/handlers/packages/counts.go b/handlers/packages/counts.go index 000f63e..5396dc6 100644 --- a/handlers/packages/counts.go +++ b/handlers/packages/counts.go @@ -1,8 +1,8 @@ package handlers_packages import ( + "brunel/buildqueue" "brunel/domain" - "brunel/helpers" "brunel/packages" "time" @@ -15,15 +15,14 @@ type CountsResponse struct { } func Counts(c *fiber.Ctx) error { - if cachedResponse, ok := helpers.Cache.Get("counts"); ok { - return c.Status(fiber.StatusOK).JSON(cachedResponse) - } - + cts := packages.GetPackagesCount() + bcts := buildqueue.GetCounts() + cts.Building = bcts.Building + cts.Queued = bcts.Queued response := CountsResponse{ LastUpdateTime: packages.LastUpdateTime, - Counts: packages.GetPackagesCount(), + Counts: cts, } - helpers.Cache.Set("counts", response) return c.Status(fiber.StatusOK).JSON(response) } diff --git a/handlers/packages/packages.go b/handlers/packages/packages.go index c4eed24..baec85f 100644 --- a/handlers/packages/packages.go +++ b/handlers/packages/packages.go @@ -3,9 +3,7 @@ package handlers_packages import ( "brunel/domain" "brunel/fastmap" - "brunel/helpers" "brunel/packages" - "fmt" "strings" "github.com/gofiber/fiber/v2" @@ -22,11 +20,6 @@ func Packages(c *fiber.Ctx) error { search := strings.ToLower(c.Query("search")) filter := c.Query("filter") - cacheKey := fmt.Sprintf("packages:%d:%d:%s:%s", pageNum, pageSize, search, filter) - if cachedResponse, ok := helpers.Cache.Get(cacheKey); ok { - return c.Status(fiber.StatusOK).JSON(cachedResponse) - } - // Adjust pageNum to be 0-based for GetPage adjustedPageNum := pageNum - 1 if adjustedPageNum < 0 { @@ -64,6 +57,5 @@ func Packages(c *fiber.Ctx) error { Packages: result, } - helpers.Cache.Set(cacheKey, response) return c.Status(fiber.StatusOK).JSON(response) } diff --git a/packages/packages.go b/packages/packages.go index a3d4563..aa936ac 100644 --- a/packages/packages.go +++ b/packages/packages.go @@ -431,5 +431,6 @@ func GetPackagesCount() domain.PackagesCount { }) return true }) + return count } diff --git a/server.go b/server.go index e6786ca..076e06e 100644 --- a/server.go +++ b/server.go @@ -92,7 +92,6 @@ func runServer(ctx context.Context) error { server.Get("/api/counts", handlers_packages.Counts) server.Get("/api/packages", handlers_packages.Packages) server.Get("/api/buildqueue", handlers_build.Queue) - server.Get("/api/buildcounts", handlers_build.Counts) server.Post("/api/login", handlers_auth.Login) adminRoutes.Post("/register", handlers_auth.Register)