Expose JUnit Report test_count directly to eliminate an extra HTTP call
Problem to solve
As part of the ongoing effort to improve the JUnit Report, we will load the summary results from a new endpoint, but currently the badge counter is filled in by an async request to another endpoint that runs in parallel. Since the JUnit data is now being stored in a database instead of an artifact, the number that needs to go in the badge counter is directly available and we should be able to just plunk it into the haml template. This would eliminate the async request and shorten the time between the page loading and the badge counter appearing.
Original comments around this idea: !33431 (comment 353956815), !33431 (comment 353987189)
Proposal
Expose the count for the badge in the Tests tab following the same pattern as the failed_builds
count.
Disclaimer: I have not tested these code snippets, they are for demonstration purposes only
- Expose the count at the pipeline level (app/serializers/pipeline_entity.rb)
expose :test_count, using: TestReportSummaryEntity do |pipeline|
pipeline.test_report_summary.total_count
end
- Use the count directly in the haml for the tab (app/views/projects/pipelines/_with_tabs.html.haml)
%span.badge.badge-pill.js-test-report-badge-counter= @pipeline.test_count