Skip to content

Commit c52afc8

Browse files
Switch build summary backend to GraphQL (#3725)
The build summary page currently loads a small portion of the data from the legacy API. This PR converts that part of the page to load the same data via GraphQL instead. This change paves the way for the build summary API endpoint to be removed, while also significantly speeding up typical page load times for the build summary page.
1 parent 506dc6f commit c52afc8

4 files changed

Lines changed: 177 additions & 362 deletions

File tree

app/Http/Controllers/BuildController.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,28 @@ public function summary(int $build_id): View
105105
{
106106
$this->setBuildById($build_id);
107107

108+
$previous_buildid = $this->build->GetPreviousBuildId();
109+
$next_buildid = $this->build->GetNextBuildId();
110+
111+
// Check if this project uses a supported bug tracker.
112+
$new_issue_url = '';
113+
$bug_tracker = '';
114+
switch ($this->project->BugTrackerType) {
115+
case 'Buganizer':
116+
case 'JIRA':
117+
case 'GitHub':
118+
$new_issue_url = RepositoryUtils::generate_bugtracker_new_issue_link($this->build, $this->project);
119+
$bug_tracker = $this->project->BugTrackerType;
120+
break;
121+
}
122+
108123
return $this->vue('build-summary', 'Build Summary', [
109124
'build-id' => $this->build->Id,
125+
'previous-build-id' => $previous_buildid,
126+
'next-build-id' => $next_buildid,
127+
'new-issue-url' => $new_issue_url,
128+
'bug-tracker' => $bug_tracker,
129+
'user-id' => Auth::id() ?? 0,
110130
]);
111131
}
112132

resources/js/vue/components/BuildSummary.vue

Lines changed: 157 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -52,38 +52,6 @@
5252
</tr>
5353
</thead>
5454
<tbody>
55-
<tr>
56-
<th>
57-
<b>Update</b>
58-
</th>
59-
<td
60-
align="right"
61-
:class="cdash.previousbuild.nupdateerrors > 0 ? 'error' : 'normal'"
62-
>
63-
<b>
64-
<a
65-
class="tw-link tw-link-hover"
66-
:href="$baseURL + '/builds/' + cdash.previousbuild.buildid + '/update'"
67-
>
68-
{{ cdash.previousbuild.nupdateerrors }}
69-
</a>
70-
</b>
71-
</td>
72-
<td
73-
align="right"
74-
:class="cdash.previousbuild.nupdatewarnings > 0 ? 'warning' : 'normal'"
75-
>
76-
<b>
77-
<a
78-
class="tw-link tw-link-hover"
79-
:href="$baseURL + '/builds/' + cdash.previousbuild.buildid + '/update'"
80-
>
81-
{{ cdash.previousbuild.nupdatewarnings }}
82-
</a>
83-
</b>
84-
</td>
85-
</tr>
86-
8755
<tr v-if="cdash.hasconfigure">
8856
<th>
8957
<b>Configure</b>
@@ -206,45 +174,6 @@
206174
</tr>
207175
</thead>
208176
<tbody>
209-
<tr>
210-
<th>
211-
<a
212-
v-if="cdash.hasupdate"
213-
href="#Update"
214-
>
215-
<b>Update</b>
216-
</a>
217-
<span v-if="!cdash.hasupdate">
218-
Update
219-
</span>
220-
</th>
221-
<td
222-
align="right"
223-
:class="cdash.update.nerrors > 0 ? 'error' : 'normal'"
224-
>
225-
<b>
226-
<a
227-
class="tw-link tw-link-hover"
228-
:href="$baseURL + '/builds/' + cdash.build.id + '/update'"
229-
>
230-
{{ cdash.update.nerrors }}
231-
</a>
232-
</b>
233-
</td>
234-
<td
235-
align="right"
236-
:class="cdash.update.nwarnings > 0 ? 'warning' : 'normal'"
237-
>
238-
<b>
239-
<a
240-
class="tw-link tw-link-hover"
241-
:href="$baseURL + '/builds/' + cdash.build.id + '/update'"
242-
>
243-
{{ cdash.update.nwarnings }}
244-
</a>
245-
</b>
246-
</td>
247-
</tr>
248177
<tr v-if="cdash.hasconfigure">
249178
<th>
250179
<a
@@ -386,38 +315,6 @@
386315
</tr>
387316
</thead>
388317
<tbody>
389-
<tr>
390-
<th>
391-
<b>Update</b>
392-
</th>
393-
<td
394-
align="right"
395-
:class="cdash.nextbuild.nupdateerrors > 0 ? 'error' : 'normal'"
396-
>
397-
<b>
398-
<a
399-
class="tw-link tw-link-hover"
400-
:href="$baseURL + '/builds/' + cdash.nextbuild.buildid + '/update'"
401-
>
402-
{{ cdash.nextbuild.nupdateerrors }}
403-
</a>
404-
</b>
405-
</td>
406-
<td
407-
align="right"
408-
:class="cdash.nextbuild.nupdatewarnings > 0 ? 'warning' : 'normal'"
409-
>
410-
<b>
411-
<a
412-
class="tw-link tw-link-hover"
413-
:href="$baseURL + '/builds/' + cdash.nextbuild.buildid + '/update'"
414-
>
415-
{{ cdash.nextbuild.nupdatewarnings }}
416-
</a>
417-
</b>
418-
</td>
419-
</tr>
420-
421318
<tr v-if="cdash.hasconfigure">
422319
<th>
423320
<b>Configure</b>
@@ -461,7 +358,7 @@
461358
<b>
462359
<a
463360
class="tw-link tw-link-hover"
464-
:href="$baseURL + '/builds/' + cdash.nextbuild.buildid + 'errors'"
361+
:href="$baseURL + '/builds/' + cdash.nextbuild.buildid + '/build'"
465362
>
466363
{{ cdash.nextbuild.nerrors }}
467364
</a>
@@ -728,7 +625,6 @@
728625

729626
<script>
730627
import $ from 'jquery';
731-
import ApiLoader from './shared/ApiLoader';
732628
import {
733629
faQuestionCircle,
734630
} from '@fortawesome/free-solid-svg-icons';
@@ -748,6 +644,26 @@ export default {
748644
type: Number,
749645
required: true,
750646
},
647+
previousBuildId: {
648+
type: Number,
649+
default: 0,
650+
},
651+
nextBuildId: {
652+
type: Number,
653+
default: 0,
654+
},
655+
newIssueUrl: {
656+
type: String,
657+
default: '',
658+
},
659+
bugTracker: {
660+
type: String,
661+
default: '',
662+
},
663+
userId: {
664+
type: Number,
665+
default: 0,
666+
},
751667
},
752668
753669
data () {
@@ -780,6 +696,133 @@ export default {
780696
},
781697
782698
apollo: {
699+
buildData: {
700+
query: gql`
701+
query BuildSummary($buildId: ID!, $prevId: ID, $nextId: ID, $hasPrev: Boolean!, $hasNext: Boolean!) {
702+
buildData: build(id: $buildId) {
703+
id
704+
name
705+
startTime
706+
buildType
707+
configureErrorsCount
708+
configureWarningsCount
709+
buildErrorsCount
710+
buildWarningsCount
711+
failedTestsCount
712+
notRunTestsCount
713+
site {
714+
id
715+
name
716+
}
717+
project {
718+
id
719+
name
720+
}
721+
configure {
722+
id
723+
}
724+
}
725+
prevBuild: build(id: $prevId) @include(if: $hasPrev) {
726+
id
727+
configureErrorsCount
728+
configureWarningsCount
729+
buildErrorsCount
730+
buildWarningsCount
731+
failedTestsCount
732+
notRunTestsCount
733+
}
734+
nextBuild: build(id: $nextId) @include(if: $hasNext) {
735+
id
736+
configureErrorsCount
737+
configureWarningsCount
738+
buildErrorsCount
739+
buildWarningsCount
740+
failedTestsCount
741+
notRunTestsCount
742+
}
743+
}
744+
`,
745+
variables() {
746+
return {
747+
buildId: this.buildId,
748+
prevId: this.previousBuildId || null,
749+
nextId: this.nextBuildId || null,
750+
hasPrev: !!this.previousBuildId,
751+
hasNext: !!this.nextBuildId,
752+
};
753+
},
754+
result({ data }) {
755+
this.loading = false;
756+
const build = data.buildData;
757+
758+
this.cdash.newissueurl = this.newIssueUrl;
759+
this.cdash.bugtracker = this.bugTracker;
760+
761+
if (data.prevBuild) {
762+
const prev = data.prevBuild;
763+
this.cdash.previousbuild = {
764+
buildid: prev.id,
765+
nconfigureerrors: Math.max(0, prev.configureErrorsCount),
766+
nconfigurewarnings: Math.max(0, prev.configureWarningsCount),
767+
nerrors: Math.max(0, prev.buildErrorsCount),
768+
nwarnings: Math.max(0, prev.buildWarningsCount),
769+
ntestfailed: Math.max(0, prev.failedTestsCount),
770+
ntestnotrun: Math.max(0, prev.notRunTestsCount),
771+
};
772+
}
773+
else {
774+
this.cdash.previousbuild = null;
775+
}
776+
777+
if (data.nextBuild) {
778+
const next = data.nextBuild;
779+
this.cdash.nextbuild = {
780+
buildid: next.id,
781+
nconfigureerrors: Math.max(0, next.configureErrorsCount),
782+
nconfigurewarnings: Math.max(0, next.configureWarningsCount),
783+
nerrors: Math.max(0, next.buildErrorsCount),
784+
nwarnings: Math.max(0, next.buildWarningsCount),
785+
ntestfailed: Math.max(0, next.failedTestsCount),
786+
ntestnotrun: Math.max(0, next.notRunTestsCount),
787+
};
788+
}
789+
else {
790+
this.cdash.nextbuild = null;
791+
}
792+
793+
this.cdash.hasconfigure = !!build.configure;
794+
795+
this.cdash.build = {
796+
id: build.id,
797+
nerrors: Math.max(0, build.buildErrorsCount),
798+
nwarnings: Math.max(0, build.buildWarningsCount),
799+
name: build.name,
800+
type: build.buildType,
801+
starttime: build.startTime,
802+
sitename_encoded: encodeURIComponent(build.site.name),
803+
};
804+
805+
this.cdash.configure = {
806+
nerrors: Math.max(0, build.configureErrorsCount),
807+
nwarnings: Math.max(0, build.configureWarningsCount),
808+
};
809+
810+
this.cdash.test = {
811+
nfailed: Math.max(0, build.failedTestsCount),
812+
nnotrun: Math.max(0, build.notRunTestsCount),
813+
};
814+
815+
this.cdash.projectname_encoded = encodeURIComponent(build.project.name);
816+
this.cdash.user = {
817+
id: this.userId,
818+
};
819+
},
820+
error(error) {
821+
this.errored = true;
822+
this.cdash.error = error;
823+
this.loading = false;
824+
},
825+
},
783826
comments: {
784827
query: gql`
785828
query($buildId: ID) {
@@ -827,9 +870,6 @@ export default {
827870
// Ensure jQuery is globally available before loading plugins
828871
window.jQuery = $;
829872
await import('flot/dist/es5/jquery.flot');
830-
831-
const endpoint_path = `/api/v1/buildSummary.php?buildid=${this.buildId}`;
832-
ApiLoader.loadPageData(this, endpoint_path);
833873
},
834874
835875
methods: {
@@ -852,19 +892,19 @@ export default {
852892
const t = build['timestamp'];
853893
854894
this.cdash.buildtimes.push([t, build['time'] / 60]);
855-
this.cdash.builderrors.push([t, build['builderrors']]);
856-
this.cdash.buildwarnings.push([t, build['buildwarnings']]);
857-
this.cdash.testfailed.push([t, build['testfailed']]);
895+
this.cdash.builderrors.push([t, Math.max(0, build['builderrors'])]);
896+
this.cdash.buildwarnings.push([t, Math.max(0, build['buildwarnings'])]);
897+
this.cdash.testfailed.push([t, Math.max(0, build['testfailed'])]);
858898
this.cdash.buildids[t] = build['id'];
859899
860900
const history_build = [];
861901
history_build['id'] = build['id'];
862-
history_build['nfiles'] = build['nfiles'];
863-
history_build['configureerrors'] = build['configureerrors'];
864-
history_build['configurewarnings'] = build['configurewarnings'];
865-
history_build['builderrors'] = build['builderrors'];
866-
history_build['buildwarnings'] = build['buildwarnings'];
867-
history_build['testfailed'] = build['testfailed'];
902+
history_build['nfiles'] = Math.max(0, build['nfiles']);
903+
history_build['configureerrors'] = Math.max(0, build['configureerrors']);
904+
history_build['configurewarnings'] = Math.max(0, build['configurewarnings']);
905+
history_build['builderrors'] = Math.max(0, build['builderrors']);
906+
history_build['buildwarnings'] = Math.max(0, build['buildwarnings']);
907+
history_build['testfailed'] = Math.max(0, build['testfailed']);
868908
history_build['starttime'] = build['starttime'];
869909
this.cdash.buildhistory.push(history_build);
870910
}

tests/Spec/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ function(add_jest_test TestName)
66
)
77
endfunction()
88

9-
add_jest_test(build-summary)
109
add_jest_test(repository-integrations)

0 commit comments

Comments
 (0)