Module: Myreplicator::ApplicationHelper

Defined in:
app/helpers/myreplicator/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#chronos(secs) ⇒ Object



11
12
13
14
15
16
17
18
# File 'app/helpers/myreplicator/application_helper.rb', line 11

def chronos(secs)
  [[60, :seconds], [60, :minutes], [24, :hours], [1000, :days]].map{ |count, name|
    if secs > 0
      secs, n = secs.divmod(count)
      "#{n.to_i} #{name}"
    end
  }.compact.reverse.join(', ')
end

#export_err_countObject



20
21
22
# File 'app/helpers/myreplicator/application_helper.rb', line 20

def export_err_count
  count = Log.where("state = 'error' AND job_type = 'export'").count
end

#loader_err_countObject



29
30
31
# File 'app/helpers/myreplicator/application_helper.rb', line 29

def loader_err_count
  count = Log.where("state = 'error' AND job_type = 'loader'").count
end

#run_countObject



25
26
27
# File 'app/helpers/myreplicator/application_helper.rb', line 25

def run_count
  total = Log.where(:state => 'running').count
end

#sortable(column, title = nil) ⇒ Object



4
5
6
7
8
9
# File 'app/helpers/myreplicator/application_helper.rb', line 4

def sortable(column, title = nil)
  title ||= column.titleize
  css_class = column == sort_column ? "current #{sort_direction}" : nil
  direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc"
  link_to (:span, title), {:sort => column, :direction => direction}, {:class => css_class}
end

#transporter_err_countObject



33
34
35
# File 'app/helpers/myreplicator/application_helper.rb', line 33

def transporter_err_count
  count = Log.where("state = 'error' AND job_type = 'transporter'").count
end

#under_maintenanceObject



37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/helpers/myreplicator/application_helper.rb', line 37

def under_maintenance
  #@redis = Redis.new(:host => 'localhost', :port => 6379)
  @redis = Redis.new(:host => Settings[:redis][:host], :port => Settings[:redis][:port])
  tmp = @redis.get "under_maintenance"
  puts tmp.class
  if tmp == "true"
    puts "===== ADASHKJDHJASKHDLASJLKDJALKS ====="
    puts tmp
    return true
  end
  return false
end