Class: Myreplicator::HomeController

Inherits:
ApplicationController show all
Defined in:
app/controllers/myreplicator/home_controller.rb

Instance Method Summary collapse

Instance Method Details

#export_errorsObject



18
19
20
21
22
23
24
# File 'app/controllers/myreplicator/home_controller.rb', line 18

def export_errors
  @tab = 'home'
  @option = 'errors'
  @exports = Export.where("error is not null").order('source_schema ASC')    
  @logs = Log.where("state = 'error' AND job_type = 'export'").order("id DESC").limit(200)
  @count = Log.where("state = 'error' AND job_type = 'export'").count
end

#indexObject



6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/myreplicator/home_controller.rb', line 6

def index  
  @tab = 'home'
  @option = 'overview'
  @exports = Export.order('state DESC')
  @logs = Log.where(:state => 'running').order("id DESC")
  @now = Time.zone.now
  respond_to do |format|
    format.html # index.html.erb
    format.json { render json: @exports }
  end
end

#killObject



41
42
43
44
45
# File 'app/controllers/myreplicator/home_controller.rb', line 41

def kill
  @log = Log.find(params[:id])
  @log.kill
  redirect_to :action => 'index' 
end

#load_errorsObject



33
34
35
36
37
38
# File 'app/controllers/myreplicator/home_controller.rb', line 33

def load_errors
  @tab = 'home'
  @option = 'errors'
  @logs = Log.where("state = 'error' AND job_type = 'loader'").order("id DESC").limit(200)
  @count = Log.where("state = 'error' AND job_type = 'loader'").count
end

#pauseObject



47
48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/myreplicator/home_controller.rb', line 47

def pause
  flash[:notice] = "Pause All DR Jobs"
  require 'rake'
  Rake::Task.load(Rails.root.to_s + "/lib/tasks/" + "maintenance.rake")
  resque_reload = Rake::Task['maintenance:stop_dr_jobs']
  resque_reload.reenable
  resque_reload.execute(ENV["RAILS_ENV"])
  @redis = Redis.new(:host => Settings[:redis][:host], :port => Settings[:redis][:port])
  @redis.set "under_maintenance", "true"
  redirect_to :action => 'index'
end

#resumeObject



59
60
61
62
63
64
65
66
67
68
69
# File 'app/controllers/myreplicator/home_controller.rb', line 59

def resume
  flash[:notice] = "Resume All DR Jobs"
  require 'rake'
  Rake::Task.load(Rails.root.to_s + "/lib/tasks/" + "maintenance.rake")
  resque_reload = Rake::Task['maintenance:start_dr_jobs']
  resque_reload.reenable
  resque_reload.execute(ENV["RAILS_ENV"])
  @redis = Redis.new(:host => Settings[:redis][:host], :port => Settings[:redis][:port])
  @redis.set "under_maintenance", "false"
  redirect_to :action => 'index'
end

#transport_errorsObject



26
27
28
29
30
31
# File 'app/controllers/myreplicator/home_controller.rb', line 26

def transport_errors
  @tab = 'home'
  @option = 'errors'
  @logs = Log.where("state = 'error' AND job_type = 'transporter'").order("id DESC").limit(200)
  @count = Log.where("state = 'error' AND job_type = 'transporter'").count
end