30 lines
601 B
Go
30 lines
601 B
Go
package handlers_build
|
|
|
|
import (
|
|
"brunel/domain"
|
|
"brunel/helpers"
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
"golang.org/x/exp/slog"
|
|
)
|
|
|
|
type ErroredResponse struct {
|
|
Total int `json:"total"`
|
|
Packages []domain.BuildState `json:"packages"`
|
|
}
|
|
|
|
func Errored(c *fiber.Ctx) error {
|
|
states, err := helpers.DBInst.GetFailedBuilds()
|
|
if err != nil {
|
|
slog.Error(err.Error())
|
|
return c.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
|
}
|
|
|
|
response := ErroredResponse{
|
|
Total: len(states),
|
|
Packages: states,
|
|
}
|
|
|
|
return c.Status(fiber.StatusOK).JSON(response)
|
|
}
|