diff --git a/api/raw.go b/api/raw.go index 4d6d0cb8..34fe6726 100644 --- a/api/raw.go +++ b/api/raw.go @@ -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()) @@ -38,4 +40,4 @@ func UptimeRaw(c *fiber.Ctx) error { c.Set("Cache-Control", "no-cache, no-store, must-revalidate") c.Set("Expires", "0") return c.Status(200).Send([]byte(fmt.Sprintf("%f", uptime))) -} \ No newline at end of file +} diff --git a/api/raw_test.go b/api/raw_test.go index 293f2b17..d227c0aa 100644 --- a/api/raw_test.go +++ b/api/raw_test.go @@ -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",