Merge branch 'add-1000-plus-counters-for-jobs-page' into 'master'
Add 1000 plus counters for jobs page See merge request gitlab-org/gitlab-ce!14507
This commit is contained in:
commit
4299df0439
|
@ -11,7 +11,7 @@ class Projects::JobsController < Projects::ApplicationController
|
||||||
def index
|
def index
|
||||||
@scope = params[:scope]
|
@scope = params[:scope]
|
||||||
@all_builds = project.builds.relevant
|
@all_builds = project.builds.relevant
|
||||||
@builds = @all_builds.order('created_at DESC')
|
@builds = @all_builds.order('ci_builds.id DESC')
|
||||||
@builds =
|
@builds =
|
||||||
case @scope
|
case @scope
|
||||||
when 'pending'
|
when 'pending'
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
module NumbersHelper
|
||||||
|
def limited_counter_with_delimiter(resource, **options)
|
||||||
|
limit = options.fetch(:limit, 1000).to_i
|
||||||
|
count = resource.limit(limit + 1).count(:all)
|
||||||
|
if count > limit
|
||||||
|
number_with_delimiter(count - 1, options) + '+'
|
||||||
|
else
|
||||||
|
number_with_delimiter(count, options)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
.nav-controls
|
.nav-controls
|
||||||
- if can?(current_user, :update_build, @project)
|
- if can?(current_user, :update_build, @project)
|
||||||
- if @all_builds.running_or_pending.any?
|
- if @all_builds.running_or_pending.limit(1).any?
|
||||||
= link_to 'Cancel running', cancel_all_project_jobs_path(@project),
|
= link_to 'Cancel running', cancel_all_project_jobs_path(@project),
|
||||||
data: { confirm: 'Are you sure?' }, class: 'btn btn-danger', method: :post
|
data: { confirm: 'Are you sure?' }, class: 'btn btn-danger', method: :post
|
||||||
|
|
||||||
|
|
|
@ -3,22 +3,22 @@
|
||||||
= link_to build_path_proc.call(nil) do
|
= link_to build_path_proc.call(nil) do
|
||||||
All
|
All
|
||||||
%span.badge.js-totalbuilds-count
|
%span.badge.js-totalbuilds-count
|
||||||
= number_with_delimiter(all_builds.count(:id))
|
= limited_counter_with_delimiter(all_builds)
|
||||||
|
|
||||||
%li{ class: active_when(scope == 'pending') }>
|
%li{ class: active_when(scope == 'pending') }>
|
||||||
= link_to build_path_proc.call('pending') do
|
= link_to build_path_proc.call('pending') do
|
||||||
Pending
|
Pending
|
||||||
%span.badge
|
%span.badge
|
||||||
= number_with_delimiter(all_builds.pending.count(:id))
|
= limited_counter_with_delimiter(all_builds.pending)
|
||||||
|
|
||||||
%li{ class: active_when(scope == 'running') }>
|
%li{ class: active_when(scope == 'running') }>
|
||||||
= link_to build_path_proc.call('running') do
|
= link_to build_path_proc.call('running') do
|
||||||
Running
|
Running
|
||||||
%span.badge
|
%span.badge
|
||||||
= number_with_delimiter(all_builds.running.count(:id))
|
= limited_counter_with_delimiter(all_builds.running)
|
||||||
|
|
||||||
%li{ class: active_when(scope == 'finished') }>
|
%li{ class: active_when(scope == 'finished') }>
|
||||||
= link_to build_path_proc.call('finished') do
|
= link_to build_path_proc.call('finished') do
|
||||||
Finished
|
Finished
|
||||||
%span.badge
|
%span.badge
|
||||||
= number_with_delimiter(all_builds.finished.count(:id))
|
= limited_counter_with_delimiter(all_builds.finished)
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Add 1000+ counters to job page
|
||||||
|
merge_request:
|
||||||
|
author:
|
||||||
|
type: fixed
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Sort JobsController by id, not created_at
|
||||||
|
merge_request:
|
||||||
|
author:
|
||||||
|
type: fixed
|
Loading…
Reference in New Issue