mirror of
https://github.com/TwiN/gatus.git
synced 2024-11-27 18:33:31 +01:00
Support 30d Data from Raw Uptime Endpoint
Signed-off-by: James Hillyard <james.hillyard@payara.fish>
This commit is contained in:
parent
7d028f5a5f
commit
67f84da9b4
@ -14,6 +14,8 @@ func UptimeRaw(c *fiber.Ctx) error {
|
||||
duration := c.Params("duration")
|
||||
var from time.Time
|
||||
switch duration {
|
||||
case "30d":
|
||||
from = time.Now().Add(-30 * 24 * time.Hour)
|
||||
case "7d":
|
||||
from = time.Now().Add(-7 * 24 * time.Hour)
|
||||
case "24h":
|
||||
@ -21,7 +23,7 @@ func UptimeRaw(c *fiber.Ctx) error {
|
||||
case "1h":
|
||||
from = time.Now().Add(-2 * time.Hour) // Because uptime metrics are stored by hour, we have to cheat a little
|
||||
default:
|
||||
return c.Status(400).SendString("Durations supported: 7d, 24h, 1h")
|
||||
return c.Status(400).SendString("Durations supported: 30d,7d, 24h, 1h")
|
||||
}
|
||||
key := c.Params("key")
|
||||
uptime, err := store.Get().GetUptimeByKey(key, from, time.Now())
|
||||
|
@ -59,6 +59,11 @@ func TestRawDataEndpoint(t *testing.T) {
|
||||
Path: "/api/v1/endpoints/core_frontend/uptimes/7d",
|
||||
ExpectedCode: http.StatusOK,
|
||||
},
|
||||
{
|
||||
Name: "raw-uptime-30d",
|
||||
Path: "/api/v1/endpoints/core_frontend/uptimes/30d",
|
||||
ExpectedCode: http.StatusOK,
|
||||
},
|
||||
{
|
||||
Name: "raw-uptime-with-invalid-duration",
|
||||
Path: "/api/v1/endpoints/core_backend/uptimes/3d",
|
||||
|
Loading…
Reference in New Issue
Block a user