From aa47157c8ec3df5a6d16e3866b095c8f91026465 Mon Sep 17 00:00:00 2001 From: Taras Madan Date: Wed, 29 Jan 2025 10:06:00 +0100 Subject: dashboard/app: change coverage links It will simplify the json API links. --- dashboard/app/coverage_test.go | 6 +++--- dashboard/app/main.go | 15 ++++++++++++--- dashboard/app/templates/templates.html | 8 ++++---- 3 files changed, 19 insertions(+), 10 deletions(-) (limited to 'dashboard') diff --git a/dashboard/app/coverage_test.go b/dashboard/app/coverage_test.go index ef8321c9f..c4945ab09 100644 --- a/dashboard/app/coverage_test.go +++ b/dashboard/app/coverage_test.go @@ -29,7 +29,7 @@ func TestFileCoverage(t *testing.T) { name: "empty db", covDB: func(t *testing.T) spannerclient.SpannerClient { return emptyCoverageDBFixture(t, 1) }, fileProv: func(t *testing.T) covermerger.FileVersProvider { return staticFileProvider(t) }, - url: "/test2/graph/coverage/file?dateto=2025-01-31&period=month" + + url: "/test2/coverage/file?dateto=2025-01-31&period=month" + "&commit=c0e75905caf368e19aab585d20151500e750de89&filepath=virt/kvm/kvm_main.c", wantInRes: []string{"1 line1"}, }, @@ -37,7 +37,7 @@ func TestFileCoverage(t *testing.T) { name: "regular db", covDB: func(t *testing.T) spannerclient.SpannerClient { return coverageDBFixture(t) }, fileProv: func(t *testing.T) covermerger.FileVersProvider { return staticFileProvider(t) }, - url: "/test2/graph/coverage/file?dateto=2025-01-31&period=month" + + url: "/test2/coverage/file?dateto=2025-01-31&period=month" + "&commit=c0e75905caf368e19aab585d20151500e750de89&filepath=virt/kvm/kvm_main.c", wantInRes: []string{ "4 1 line1", @@ -48,7 +48,7 @@ func TestFileCoverage(t *testing.T) { name: "multimanager db", covDB: func(t *testing.T) spannerclient.SpannerClient { return multiManagerCovDBFixture(t) }, fileProv: func(t *testing.T) covermerger.FileVersProvider { return staticFileProvider(t) }, - url: "/test2/graph/coverage/file?dateto=2025-01-31&period=month" + + url: "/test2/coverage/file?dateto=2025-01-31&period=month" + "&commit=c0e75905caf368e19aab585d20151500e750de89&filepath=virt/kvm/kvm_main.c" + "&manager=special-cc-manager&unique-only=1", wantInRes: []string{ diff --git a/dashboard/app/main.go b/dashboard/app/main.go index 071dc8544..93ee73c00 100644 --- a/dashboard/app/main.go +++ b/dashboard/app/main.go @@ -65,11 +65,14 @@ func initHTTPHandlers() { http.Handle("/"+ns+"/graph/fuzzing", handlerWrapper(handleGraphFuzzing)) http.Handle("/"+ns+"/graph/crashes", handlerWrapper(handleGraphCrashes)) http.Handle("/"+ns+"/graph/found-bugs", handlerWrapper(handleFoundBugsGraph)) - http.Handle("/"+ns+"/graph/coverage/file", handlerWrapper(handleFileCoverage)) http.Handle("/"+ns+"/graph/coverage", handlerWrapper(handleCoverageGraph)) - http.Handle("/"+ns+"/graph/coverage_heatmap", handlerWrapper(handleCoverageHeatmap)) + http.Handle("/"+ns+"/coverage/file", handlerWrapper(handleFileCoverage)) + http.Handle("/"+ns+"/coverage", handlerWrapper(handleCoverageHeatmap)) + http.Handle("/"+ns+"/graph/coverage_heatmap", handleMovedPermanently("/"+ns+"/coverage")) if nsConfig.Subsystems.Service != nil { - http.Handle("/"+ns+"/graph/coverage_subsystems_heatmap", handlerWrapper(handleSubsystemsCoverageHeatmap)) + http.Handle("/"+ns+"/graph/coverage_subsystems_heatmap", + handleMovedPermanently("/"+ns+"/coverage/subsystems")) + http.Handle("/"+ns+"/coverage/subsystems", handlerWrapper(handleSubsystemsCoverageHeatmap)) } http.Handle("/"+ns+"/repos", handlerWrapper(handleRepos)) http.Handle("/"+ns+"/bug-summaries", handlerWrapper(handleBugSummaries)) @@ -85,6 +88,12 @@ func initHTTPHandlers() { http.HandleFunc("/cron/subsystem_reports", handleSubsystemReports) } +func handleMovedPermanently(dest string) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + http.Redirect(w, r, dest, http.StatusMovedPermanently) + } +} + type uiMainPage struct { Header *uiHeader Now time.Time diff --git a/dashboard/app/templates/templates.html b/dashboard/app/templates/templates.html index 0f859f715..bcf1551fa 100644 --- a/dashboard/app/templates/templates.html +++ b/dashboard/app/templates/templates.html @@ -106,11 +106,11 @@ Use of this source code is governed by Apache 2 LICENSE that can be found in the -- cgit mrf-deployment