From 93777f1898d8c7bfb498a47a4f8500c8c3f43523 Mon Sep 17 00:00:00 2001 From: William Allen Date: Wed, 18 Nov 2026 17:58:25 -0500 Subject: [PATCH] Add filters to build and test trend charts The test trend and build history charts only ever showed builds with the same site, name and type as the current build. Each chart now has small dropdowns to widen that to all sites, all groups and, on the test chart, all build names, plus a choice of how many builds to show. The defaults match the old behavior, and each chart remembers the user's choices in local storage. "Show History" now uses the same filters and time window as the chart, and for SubProject builds it lists that SubProject's builds instead of parent builds. When the plotted builds differ, tooltips show which site, build or group each bar is from, and the chart dims instead of flashing while it reloads. This also fixes the clipped "Total Time" axis label on the build chart. --- .../js/vue/components/BuildSummaryPage.vue | 107 ++++++++-- .../BuildSummaryPage/BuildTimeChart.vue | 18 +- resources/js/vue/components/TestIdPage.vue | 4 +- .../components/TestIdPage/TestTrendChart.vue | 134 +++++++++---- .../vue/components/shared/TrendFilterBar.vue | 146 ++++++++++++++ .../js/vue/components/shared/TrendFilters.js | 159 +++++++++++++++ .../shared/legacy/filters/filterUrls.js | 13 +- tests/Browser/Pages/BuildSummaryPageTest.php | 187 +++++++++++++++++- tests/Browser/Pages/TestsIdPageTest.php | 114 ++++++++++- tests/Spec/CMakeLists.txt | 1 + tests/Spec/trend-filters.spec.js | 102 ++++++++++ 11 files changed, 917 insertions(+), 68 deletions(-) create mode 100644 resources/js/vue/components/shared/TrendFilterBar.vue create mode 100644 resources/js/vue/components/shared/TrendFilters.js create mode 100644 tests/Spec/trend-filters.spec.js diff --git a/resources/js/vue/components/BuildSummaryPage.vue b/resources/js/vue/components/BuildSummaryPage.vue index bcd2b86bb4..e40046c537 100644 --- a/resources/js/vue/components/BuildSummaryPage.vue +++ b/resources/js/vue/components/BuildSummaryPage.vue @@ -422,20 +422,33 @@
- @@ -455,11 +468,13 @@ import BuildSidebar from './shared/BuildSidebar.vue'; import BuildTimelineCard from './BuildSummaryPage/BuildTimelineCard.vue'; import gql from 'graphql-tag'; import BuildTimeChart from './BuildSummaryPage/BuildTimeChart.vue'; +import TrendFilterBar from './shared/TrendFilterBar.vue'; +import { loadTrendFilters, saveTrendFilters, trendBuildConditions, trendHistoryFilterParams } from './shared/TrendFilters'; import { DateTime, Duration } from 'luxon'; export default { name: 'BuildSummaryPage', - components: { BuildTimelineCard, BuildTimeChart, BuildSummaryCard, LoadingIndicator, BuildSidebar, FontAwesomeIcon }, + components: { BuildTimelineCard, BuildTimeChart, BuildSummaryCard, LoadingIndicator, BuildSidebar, FontAwesomeIcon, TrendFilterBar }, props: { projectId: { @@ -495,6 +510,7 @@ export default { cdash: {}, loading: true, errored: false, + trendFilters: loadTrendFilters('build'), }; }, @@ -523,6 +539,7 @@ export default { } subProject { id + name } project { id @@ -604,10 +621,6 @@ export default { id: build.id, nerrors: Math.max(0, build.buildErrorsCount), nwarnings: Math.max(0, build.buildWarningsCount), - name_encoded: encodeURIComponent(build.name), - type_encoded: encodeURIComponent(build.buildType), - starttime_encoded: encodeURIComponent(build.startTime), - sitename_encoded: encodeURIComponent(build.site.name), }; this.cdash.configure = { @@ -620,8 +633,6 @@ export default { nnotrun: Math.max(0, build.notRunTestsCount), npassed: Math.max(0, build.passedTestsCount), }; - - this.cdash.projectname_encoded = encodeURIComponent(build.project.name); }, error(error) { this.errored = true; @@ -631,11 +642,11 @@ export default { }, buildHistory: { query: gql` - query($projectId: ID, $filters: ProjectBuildsFiltersMultiFilterInput, $onlyParents: Boolean) { + query($projectId: ID, $limit: Int!, $filters: ProjectBuildsFiltersMultiFilterInput, $onlyParents: Boolean) { project(id: $projectId) { id builds( - first: 100, + first: $limit, orderBy: [{column: START_TIME, order: DESC}], filters: $filters onlyParents: $onlyParents @@ -643,7 +654,13 @@ export default { edges { node { id + name + buildType startTime + site { + id + name + } configureDuration buildDuration testDuration @@ -660,6 +677,7 @@ export default { variables() { return { projectId: this.projectId, + limit: this.trendFilters.limit, filters: this.buildHistoryFilters, onlyParents: this.isParentBuild, }; @@ -687,9 +705,11 @@ export default { } const build = this.buildData; const conditions = [ - { eq: { name: build.name } }, - { eq: { buildType: build.buildType } }, - { has: { site: { eq: { id: build.site.id } } } }, + ...trendBuildConditions(this.historyFilters, { + name: build.name, + buildType: build.buildType, + siteId: build.site.id, + }), { le: { startTime: build.startTime } }, ]; if (build.subProject) { @@ -698,6 +718,42 @@ export default { return { all: conditions }; }, + /** + * The build history is the history of builds with this build's name, so that filter is always applied. + */ + historyFilters() { + return { + ...this.trendFilters, + sameName: true, + }; + }, + + trendFilterBuild() { + return { + siteName: this.buildData?.site.name ?? '', + name: this.buildData?.name ?? '', + group: this.buildData?.buildType ?? '', + }; + }, + + /** + * The builds page, filtered to the builds in the build history chart. + */ + buildHistoryUrl() { + if (!this.buildData || !this.buildHistory || this.buildHistory.length === 0) { + return ''; + } + const build = this.buildData; + const params = trendHistoryFilterParams(this.historyFilters, { + name: build.name, + buildType: build.buildType, + siteName: build.site.name, + startTime: build.startTime, + }, this.buildHistory.at(-1).node.startTime); + const subproject = build.subProject ? `&subproject=${encodeURIComponent(build.subProject.name)}` : ''; + return `${this.$baseURL}/index.php?project=${encodeURIComponent(build.project.name)}${subproject}&${params}`; + }, + buildTimeData() { if (!this.buildHistory) { return []; @@ -706,6 +762,9 @@ export default { const build = edge.node; return { buildId: build.id, + buildName: build.name, + buildType: build.buildType, + siteName: build.site.name, configureTime: Duration.fromObject({ seconds: Math.max(build.configureDuration, 0) }), buildTime: Duration.fromObject({ seconds: Math.max(build.buildDuration, 0) }), testTime: Duration.fromObject({ seconds: Math.max(build.testDuration, 0) }), @@ -718,6 +777,12 @@ export default { }, }, + watch: { + trendFilters(filters) { + saveTrendFilters('build', filters); + }, + }, + methods: { }, }; diff --git a/resources/js/vue/components/BuildSummaryPage/BuildTimeChart.vue b/resources/js/vue/components/BuildSummaryPage/BuildTimeChart.vue index 000b8b60f5..49c1def53b 100644 --- a/resources/js/vue/components/BuildSummaryPage/BuildTimeChart.vue +++ b/resources/js/vue/components/BuildSummaryPage/BuildTimeChart.vue @@ -3,6 +3,8 @@ class="tw-w-full tw-h-60 tw-cursor-pointer" :option="chartOption" autoresize + data-test="build-time-chart" + :data-test-point-count="data.length" @click="handleChartClick" >