module RRRSpec::Server::StatisticsUpdater
Constants
- ESTIMATION_FIELDS
Public Instance Methods
recalculate_estimate_sec(taskset)
click to toggle source
# File lib/rrrspec/server/statistics_updater.rb, line 38 def recalculate_estimate_sec(taskset) RRRSpec.logger.debug("Calculating estimate sec for taskset #{taskset.key}") start = Time.now p_obj = Persistence::Taskset.where(key: taskset.key).first taskset_class = p_obj.taskset_class query = Persistence::Task.joins(:trials).joins(:taskset). select(ESTIMATION_FIELDS). where('tasksets.taskset_class' => taskset_class). where('trials.status' => ["passed", "pending"]). group('spec_file') estimation = {} query.each do |row| estimation[row.spec_file] = row.avg.to_i end unless estimation.empty? TasksetEstimation.update_estimate_secs(taskset_class, estimation) end RRRSpec.logger.info("Recalculated estimate sec for taskset #{taskset.key} (total: #{Time.now - start} seconds)") end
update_estimate_sec(taskset)
click to toggle source
# File lib/rrrspec/server/statistics_updater.rb, line 35 def update_estimate_sec(taskset) end
work()
click to toggle source
# File lib/rrrspec/server/statistics_updater.rb, line 16 def work taskset, recalculate = StatisticsUpdaterQueue.dequeue recalculate = true ActiveRecord::Base.connection_pool.with_connection do unless Persistence::Taskset.where(key: taskset.key).exists? RRRSpec.logger.warn("StatisticsUpdater: Ignoreing unpersisted taskset: #{taskset.key}") end if recalculate recalculate_estimate_sec taskset else update_estimate_sec taskset end end rescue RRRSpec.logger.error($!) end
work_loop()
click to toggle source
# File lib/rrrspec/server/statistics_updater.rb, line 12 def work_loop loop { work } end