30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'app/controllers/dispatch_policy/policies_controller.rb', line 30
def show
scope = StagedJob.where(policy_name: @policy_name)
@pending_count = scope.pending.count
@pending_eligible_count = scope.pending.where("not_before_at IS NULL OR not_before_at <= ?", Time.current).count
@pending_scheduled_count = @pending_count - @pending_eligible_count
@admitted_count = scope.admitted.count
@completed_24h = scope.completed.where(completed_at: 24.hours.ago..).count
all_breakdown = partition_breakdown(scope)
@watched_keys = (params[:watch] || "").split(",").map(&:strip).reject(&:empty?)
@partition_breakdown = @watched_keys.any? ? all_breakdown.select { |r| @watched_keys.include?(r[:partition]) } : []
@partition_search = params[:q].to_s.strip
@partition_page = [ params[:page].to_i, 1 ].max
@partition_sort = %w[source partition pending in_flight completed_24h last_enqueued_at last_dispatched_at].include?(params[:sort]) ? params[:sort] : "activity"
@partition_dir = params[:dir] == "asc" ? "asc" : "desc"
list = all_breakdown
list = list.select { |r| r[:partition].to_s.downcase.include?(@partition_search.downcase) } if @partition_search.present?
list = sort_partition_list(list, @partition_sort, @partition_dir)
@partition_total_list = list.size
offset = (@partition_page - 1) * PARTITION_LIST_PAGE_SIZE
@partition_list = list[offset, PARTITION_LIST_PAGE_SIZE] || []
load_adaptive_chart_data
@throttle_buckets = ThrottleBucket
.where(policy_name: @policy_name).order(:gate_name, :partition_key).limit(50)
@pending_jobs = scope.pending
.select(:id, :dedupe_key, :round_robin_key, :priority, :staged_at, :not_before_at)
.order(:priority, :staged_at)
.limit(50)
end
|