diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-09-12 18:13:07 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-09-14 13:20:05 +0200 |
commit | 72190099934badcb3296983a457123c9e0303060 (patch) | |
tree | e1f447f2fea15b29860475d5830016b287c81925 /app/views/projects | |
parent | 3e999684f9c3b7306dea7a7feee90536ee100ccf (diff) | |
download | gitlab-ce-72190099934badcb3296983a457123c9e0303060.tar.gz |
Memoize the latest builds of a pipelineprojects-controller-show
This ensures that if a pipeline is present for the last commit on a
project's homepage we only run 1 query to get the builds, instead of
running 2 queries.
See https://gitlab.com/gitlab-org/gitlab-ce/issues/36878#note_40073339
for more information.
Diffstat (limited to 'app/views/projects')
-rw-r--r-- | app/views/projects/buttons/_download.html.haml | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/app/views/projects/buttons/_download.html.haml b/app/views/projects/buttons/_download.html.haml index 219ccdc8164..9d85e027ac9 100644 --- a/app/views/projects/buttons/_download.html.haml +++ b/app/views/projects/buttons/_download.html.haml @@ -26,18 +26,16 @@ %i.fa.fa-download %span= _('Download tar') - - if pipeline - - artifacts = pipeline.builds.latest.with_artifacts - - if artifacts.any? - %li.dropdown-header Artifacts - - unless pipeline.latest? - - latest_pipeline = project.pipeline_for(ref) - %li - .unclickable= ci_status_for_statuseable(latest_pipeline) - %li.dropdown-header Previous Artifacts - - artifacts.each do |job| - %li - = link_to latest_succeeded_project_artifacts_path(project, "#{ref}/download", job: job.name), rel: 'nofollow', download: '' do - %i.fa.fa-download - %span - #{ s_('DownloadArtifacts|Download') } '#{job.name}' + - if pipeline && pipeline.latest_builds_with_artifacts.any? + %li.dropdown-header Artifacts + - unless pipeline.latest? + - latest_pipeline = project.pipeline_for(ref) + %li + .unclickable= ci_status_for_statuseable(latest_pipeline) + %li.dropdown-header Previous Artifacts + - pipeline.latest_builds_with_artifacts.each do |job| + %li + = link_to latest_succeeded_project_artifacts_path(project, "#{ref}/download", job: job.name), rel: 'nofollow', download: '' do + %i.fa.fa-download + %span + #{s_('DownloadArtifacts|Download')} '#{job.name}' |