Class: Debci::OldestJob
- Inherits:
-
Struct
- Object
- Struct
- Debci::OldestJob
- Defined in:
- lib/debci/oldest_job.rb
Instance Attribute Summary collapse
-
#arch ⇒ Object
Returns the value of attribute arch.
-
#oldest_job ⇒ Object
Returns the value of attribute oldest_job.
Class Method Summary collapse
Instance Attribute Details
#arch ⇒ Object
Returns the value of attribute arch
2 3 4 |
# File 'lib/debci/oldest_job.rb', line 2 def arch @arch end |
#oldest_job ⇒ Object
Returns the value of attribute oldest_job
2 3 4 |
# File 'lib/debci/oldest_job.rb', line 2 def oldest_job @oldest_job end |
Class Method Details
.fetch ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/debci/oldest_job.rb', line 15 def self.fetch query = <<-ENDQUERY SELECT arch, min(created_at) as oldest_job FROM jobs WHERE status IS NULL AND created_at > $1 GROUP by arch; ENDQUERY a_month_ago = Time.now - 1.month results = ActiveRecord::Base.connection.exec_query( query, "Oldest job in the queue", [a_month_ago] ) results.cast_values.map do |row| self.new(*row) end end |
.get ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/debci/oldest_job.rb', line 3 def self.get if !@data || !@timestamp || Time.now > (@timestamp + 1.hour) @data = fetch @timestamp = Time.now end @data end |
.reset! ⇒ Object
11 12 13 |
# File 'lib/debci/oldest_job.rb', line 11 def self.reset! @data = @timestamp = nil end |