From 4e3241f78cf3211b17716ac9dcfe6cd06f09c363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tore=20Stendal=20L=C3=B8n=C3=B8y?= Date: Wed, 5 Feb 2025 13:46:00 +0100 Subject: [PATCH] feat: add support for 1h response chart --- api/chart.go | 4 +++- api/chart_test.go | 5 +++++ web/app/src/views/Details.vue | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/api/chart.go b/api/chart.go index 81a4d11d..20e35cf8 100644 --- a/api/chart.go +++ b/api/chart.go @@ -42,8 +42,10 @@ func ResponseTimeChart(c *fiber.Ctx) error { from = time.Now().Truncate(time.Hour).Add(-7 * 24 * time.Hour) case "24h": from = time.Now().Truncate(time.Hour).Add(-24 * time.Hour) + case "1h": + from = time.Now().Add(-2 * time.Hour) // Because response time metrics are stored by hour, we have to cheat a little default: - return c.Status(400).SendString("Durations supported: 30d, 7d, 24h") + return c.Status(400).SendString("Durations supported: 30d, 7d, 24h, 1h") } hourlyAverageResponseTime, err := store.Get().GetHourlyAverageResponseTimeByKey(c.Params("key"), from, time.Now()) if err != nil { diff --git a/api/chart_test.go b/api/chart_test.go index 2a699a5b..3f146a64 100644 --- a/api/chart_test.go +++ b/api/chart_test.go @@ -39,6 +39,11 @@ func TestResponseTimeChart(t *testing.T) { Gzip bool } scenarios := []Scenario{ + { + Name: "chart-response-time-1h", + Path: "/api/v1/endpoints/core_backend/response-times/1h/chart.svg", + ExpectedCode: http.StatusOK, + }, { Name: "chart-response-time-24h", Path: "/api/v1/endpoints/core_backend/response-times/24h/chart.svg", diff --git a/web/app/src/views/Details.vue b/web/app/src/views/Details.vue index fc84695d..e35f711a 100644 --- a/web/app/src/views/Details.vue +++ b/web/app/src/views/Details.vue @@ -41,7 +41,7 @@

RESPONSE TIME

-