batch_manager 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- M2M2ODYwMWZjOWY0NjQyZTZiN2ExYjk2MTAyYzk3MzVkZTc4Mzk0Mw==
4
+ Mjc1M2YyMmMxMDA0MjlmN2I5NDZhNzJlNGUyMWVkZGRjZmZiMTljNA==
5
5
  data.tar.gz: !binary |-
6
- MjliZTg3YzE4Mzk5ZjZkZjgxY2U3MmE4MDBkNzhiYmM1Y2QzYmI5Ng==
6
+ YzZhNmQ5MDNhZjFmNTA4NDQ0Mjg2YzJjMmI2OTI2NzUzMDhjM2NlYQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ODZkMzU2MDQ1NWM0NWZjZTljOGRiM2M0NWVlMDc1ZWNhMDQzNDViZWM5NWJl
10
- ZjE3YzkxMzE5ZDE2NjYxZWQxNWI4MWE3NGZkMDNjNGI4NDg0MjhhZTJiMzIw
11
- YjE2YWRkMGYwNzIxMTFiNjlkNDc4NTBlZWM4ZGM3OTlmMjQ5N2Y=
9
+ OGE1MzRlMjFiNDY0YWFjMzEyNTcyYWNlNzc4YTgzYmViNmVhOWEyMjg3MDVj
10
+ NDFjM2QwYTY5YzFkMzE1YTFmODY5MzZkNGE4Y2U3MTdmZjkyMTdjMDAxYWY4
11
+ MmM1MDQ3ZDUxZDQ2OWI3YzE3Y2VkODBkZWU2N2Q0YjJhYmZiY2Y=
12
12
  data.tar.gz: !binary |-
13
- YzI1YWYwMWFmZjEwOThkNDFjODYxOTIwMGMwN2Q2NzMxM2MyN2I5YmExYzZl
14
- OGFlYjc4NTg4NDY5NDE0OTk5ZjdjNTJkZWFmZWMwNjg2MDg0NWQ1OTZlMjhi
15
- NjJlOTgyMjk0YTM4NmFhMmUzZmQ5NjllMTcxYjUyMmY5NGUyZTc=
13
+ MzY3YzVmNzVhMGFkMjcxYWI5NmQ3YjYzZjg0MTEyMWVmZGQ0YTNkMmZjNDA3
14
+ OTAzNjQyZGIyMjQ3ZjFkN2RmODkwNjJkNDQ1ZjEzYjg2OTIzMGQzNDZlYjUw
15
+ YjgxYzEzMWQzMWMyZTg4OTM5NGQ5NWQzYzJiYjc2NGZiMTlmMGQ=
data/README.md CHANGED
@@ -82,6 +82,8 @@ You can also use web interface to execute batches.
82
82
 
83
83
  If [resque](https://github.com/resque/resque) installed in you application, the batch script can be executed asynchronous. And the log can be checked on real time in the brower.
84
84
 
85
+ The QUEUE's name will be **"batch_manager".**
86
+
85
87
  ## Rake Tasks
86
88
 
87
89
  show all batches
@@ -56,3 +56,15 @@ tr.odd.disable {
56
56
  width: 100%;
57
57
  height:500px;
58
58
  }
59
+
60
+ .resque_label {
61
+ text-align: right;
62
+ }
63
+
64
+ .resque_label.support {
65
+ color: green;
66
+ }
67
+
68
+ .resque_label.not_support {
69
+ color: red;
70
+ }
@@ -1,4 +1,19 @@
1
1
  module BatchManager
2
2
  class ApplicationController < ActionController::Base
3
+ def resque_supported?
4
+ begin
5
+ require 'resque'
6
+ if defined?(Resque)
7
+ queue_names = []
8
+ Resque.workers.map do |worker|
9
+ queue_names += worker.id.split(':')[-1].split(',')
10
+ end
11
+ return true if queue_names.include?(BatchManager::ExecBatchWorker.queue_name) || queue_names.include?("*")
12
+ end
13
+ false
14
+ rescue
15
+ false
16
+ end
17
+ end
3
18
  end
4
19
  end
@@ -3,13 +3,14 @@ module BatchManager
3
3
  before_filter :retain_batch_params, :except => [:index]
4
4
 
5
5
  def index
6
+ @resque_supported = resque_supported?
6
7
  @details = BatchManager::Monitor.details
7
8
  end
8
9
 
9
10
  def exec
10
11
  if resque_supported?
11
12
  Resque.enqueue(BatchManager::ExecBatchWorker, @batch_name, :wet => @wet)
12
- redirect_to(log_batches_url(:batch_name => @batch_name, :wet => @wet))
13
+ redirect_to(log_batches_url(:batch_name => @batch_name, :wet => @wet, :refresh => true))
13
14
  else
14
15
  BatchManager::Executor.exec(@batch_name, :wet => @wet)
15
16
  redirect_to(batches_url)
@@ -33,15 +34,6 @@ module BatchManager
33
34
  @wet = params[:wet]
34
35
  end
35
36
 
36
- def resque_supported?
37
- begin
38
- require 'resque'
39
- defined?(Resque)
40
- rescue
41
- false
42
- end
43
- end
44
-
45
37
  def log_file
46
38
  20.times do
47
39
  begin
@@ -1,4 +1,9 @@
1
1
  <h2>Batches</h2>
2
+ <% if @resque_supported %>
3
+ <div class="resque_label support">Resque worker found</div>
4
+ <% else %>
5
+ <div class="resque_label not_support">Resque or Resque worker not found</div>
6
+ <% end %>
2
7
  <table>
3
8
  <tr>
4
9
  <th>Managed?</th>
@@ -1,3 +1,4 @@
1
+ <% if params[:refresh] %>
1
2
  <script>
2
3
  function read_log() {
3
4
  offset = $("#offset").val();
@@ -15,6 +16,7 @@
15
16
  setInterval(read_log, 1000);
16
17
  });
17
18
  </script>
19
+ <% end %>
18
20
 
19
21
  <h2><%= @batch_name %><h2>
20
22
 
@@ -6,5 +6,8 @@ module BatchManager
6
6
  BatchManager::Executor.exec(batch_name, :wet => options[:wet])
7
7
  end
8
8
 
9
+ def self.queue_name
10
+ @queue
11
+ end
9
12
  end
10
13
  end
@@ -1,3 +1,3 @@
1
1
  module BatchManager
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: batch_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Weihu Chen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-07 00:00:00.000000000 Z
11
+ date: 2013-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails