Skip to content

Commit

Permalink
Make gather_busy method private
Browse files Browse the repository at this point in the history
It's not an action since it's never used directly.
  • Loading branch information
dmarcoux committed Sep 4, 2019
1 parent d14afe8 commit 7249f9c
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/api/app/controllers/webui/main_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,6 @@
class Webui::MainController < Webui::WebuiController
skip_before_action :check_anonymous, only: [:index]

def gather_busy
busy = []
archs = Architecture.where(available: 1).map(&:worker).uniq
archs.each do |arch|
starttime = Time.now.to_i - 168.to_i * 3600
rel = StatusHistory.where("time >= ? AND \`key\` = ?", starttime, 'building_' + arch)
values = rel.pluck(:time, :value).collect! { |time, value| [time.to_i, value.to_f] }
values = StatusHelper.resample(values, 400)
if busy.empty?
busy = values
elsif values.present?
busy = add_arrays(busy, values)
end
end
busy
end

def index
@status_messages = StatusMessage.alive.includes(:user).limit(4).to_a
@workerstatus = Rails.cache.fetch('workerstatus_hash', expires_in: 10.minutes) do
Expand All @@ -45,4 +28,23 @@ def index

switch_to_webui2
end

private

def gather_busy
busy = []
archs = Architecture.where(available: 1).map(&:worker).uniq
archs.each do |arch|
starttime = Time.now.to_i - 168.to_i * 3600
rel = StatusHistory.where("time >= ? AND \`key\` = ?", starttime, 'building_' + arch)
values = rel.pluck(:time, :value).collect! { |time, value| [time.to_i, value.to_f] }
values = StatusHelper.resample(values, 400)
if busy.empty?
busy = values
elsif values.present?
busy = add_arrays(busy, values)
end
end
busy
end
end

0 comments on commit 7249f9c

Please sign in to comment.