canvas_sync 0.19.0.beta1 → 0.19.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b2a5e403bcaaaaf0fcbab739a2b9b6657ed42a5a5692de0b9d6a84e429d2a232
4
- data.tar.gz: acef06fb5cae9aa20d70e308972d9416fd8280ddb3c944718ef937679ac468b5
3
+ metadata.gz: 2d6b617272cdcd0d707dcf732e93b537aba165054ea8c3c2ddf9eb85f141b75b
4
+ data.tar.gz: 836afc2cca6c11d8917188c7cb68853c23455a450c983a738f4c21c7382e5280
5
5
  SHA512:
6
- metadata.gz: 91ed4f8c3312c398ee9bb19cad4333ddda8f738330470d4582c1c92ff00abeef12e52ff344a94edc50a726616c2533126c99b211da1a348cd18d5062a6939e40
7
- data.tar.gz: a95413c17cc1029fd5c8adb6fbd19add7a0d18fda2c8c790f71bbc57df8b51223c1a554120dd93bbedc61223c60a7f549849d1686358fe9e357af5bf20467eb1
6
+ metadata.gz: b33944c8079dc4315c71afe6998c79e83d12fa476223c81a943a75025e0faca50e4cde96a68a195d90cb66d674303666992a9f75de840ee00e0bce3beba75ba7
7
+ data.tar.gz: 931b2cc7992a8069c152cf3651544a6600603a45bb25baa3a8679011fd0c809726054d203da41cf558aa685f88e31b152f78ee78c535e40c2f487c4d0fa65746
@@ -0,0 +1,15 @@
1
+ module CanvasSync::Concerns
2
+ module Account
3
+ module Base
4
+ extend ActiveSupport::Concern
5
+
6
+ CanvasSync::Record.define_feature self, default: true
7
+
8
+ class_methods do
9
+ def root_account
10
+ where(canvas_parent_account_id: nil).last
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -23,7 +23,7 @@ module CanvasSync
23
23
  r.hset("MNGBID-#{man_batch_id}", "root_bid", root_batch.bid)
24
24
  r.hset("MNGBID-#{man_batch_id}", "ordered", ordered ? 1 : 0)
25
25
  r.hset("MNGBID-#{man_batch_id}", "concurrency", concurrency)
26
- r.hset("MNGBID-#{man_batch_id}", "preflight_check", preflight_check)
26
+ r.hset("MNGBID-#{man_batch_id}", "preflight_check", preflight_check) if preflight_check.present?
27
27
  r.expire("MNGBID-#{man_batch_id}", Batch::BID_EXPIRE_TTL)
28
28
 
29
29
  mapped_sub_jobs = sub_jobs.each_with_index.map do |j, i|
@@ -9,6 +9,7 @@ module CanvasSync
9
9
  redis_attr :description
10
10
  redis_attr :created_at
11
11
  redis_attr :concurrency, :int
12
+ redis_attr :complete_count, :int
12
13
  redis_attr :order
13
14
  redis_attr :on_failed_job, :symbol
14
15
  redis_attr :clean_when_empty, :bool
@@ -88,7 +89,7 @@ module CanvasSync
88
89
  self.order
89
90
 
90
91
  activec, pactivec, pendingc, clean_when_empty, keep_open = redis.multi do |r|
91
- r.scard("#{redis_key}-active")
92
+ r.hlen("#{redis_key}-active")
92
93
  r.hincrby(redis_key, "_active_count", 0)
93
94
  pending_count(r)
94
95
  r.hget(redis_key, 'clean_when_empty')
@@ -103,7 +104,7 @@ module CanvasSync
103
104
  end
104
105
 
105
106
  def active_count(r = redis)
106
- r.scard("#{redis_key}-active") + r.hincrby(redis_key, "_active_count", 0)
107
+ r.hlen("#{redis_key}-active") + r.hincrby(redis_key, "_active_count", 0)
107
108
  end
108
109
 
109
110
  def pending_count(r = redis)
@@ -120,7 +121,8 @@ module CanvasSync
120
121
  end
121
122
 
122
123
  def job_checked_in(status, options)
123
- redis.srem("#{redis_key}-active", status.bid)
124
+ redis.hdel("#{redis_key}-active", status.bid)
125
+ redis.hincrby(redis_key, "complete_count", 1)
124
126
  active_count = refill_allotment
125
127
  cleanup_if_empty unless active_count > 0
126
128
  end
@@ -150,7 +152,7 @@ module CanvasSync
150
152
 
151
153
  pending_job_descs = job_descs.dup
152
154
 
153
- added_jobs = []
155
+ added_jobs = {}
154
156
  failed_to_add_jobs = []
155
157
  add_exception = nil
156
158
 
@@ -165,7 +167,7 @@ module CanvasSync
165
167
  ChainBuilder.enqueue_job(job_desc)
166
168
  end
167
169
 
168
- added_jobs << wbid
170
+ added_jobs[wbid] = job_json
169
171
  rescue => ex
170
172
  failed_to_add_jobs << job_json
171
173
  add_exception = ex
@@ -173,7 +175,7 @@ module CanvasSync
173
175
  end
174
176
 
175
177
  redis.multi do |r|
176
- r.sadd("#{redis_key}-active", added_jobs) if added_jobs.count > 0
178
+ r.mapped_hmset("#{redis_key}-active", added_jobs) if added_jobs.count > 0
177
179
  # Release reserved slots now that we've added the jobs to `-active`
178
180
  r.hincrby(redis_key, "_active_count", -job_descs.count)
179
181
 
@@ -9,7 +9,7 @@ end
9
9
 
10
10
  local pool_type = redis.call('HGET', poolkey, "order")
11
11
  local allotment = tonumber(redis.call("HGET", poolkey, "concurrency"))
12
- local active = redis.call("SCARD", activekey) + (redis.call("HGET", poolkey, "_active_count") or 0)
12
+ local active = redis.call("HLEN", activekey) + (redis.call("HGET", poolkey, "_active_count") or 0)
13
13
 
14
14
  local pop_count = allotment - active
15
15
 
@@ -31,14 +31,57 @@
31
31
  <th scope=row><%= t('Pending Tasks') %></td>
32
32
  <td><%= @pool.pending_count %></td>
33
33
  </tr>
34
+ <tr>
35
+ <th scope=row><%= t('Returned Tasks') %></td>
36
+ <td><%= @pool.complete_count %></td>
37
+ </tr>
34
38
  </tbody>
35
39
  </table>
36
40
  </div>
37
41
 
42
+ <%# Queued/Active Tasks %>
43
+ <header class="row">
44
+ <div class="col-sm-5">
45
+ <h3>
46
+ <%= t('Queued/Active Tasks') %>
47
+ </h3>
48
+ </div>
49
+ </header>
50
+
51
+ <% if @active_tasks.any? %>
52
+ <div class="table_container">
53
+ <table class="table table-striped table-bordered table-hover">
54
+ <thead>
55
+ <tr>
56
+ <th><%= t('Wrapper Batch BID') %></th>
57
+ <th><%= t('Job Class') %></th>
58
+ <th><%= t('Parameters') %></th>
59
+ </tr>
60
+ </thead>
61
+
62
+ <% @active_tasks.each do |job_desc| %>
63
+ <tr>
64
+ <td><a href="<%= root_path %>batches/<%= job_desc['pool_wrapper_batch'] %>"><%= job_desc['pool_wrapper_batch'] %></a></td>
65
+ <td><%= job_desc['job'] %></td>
66
+ <td>
67
+ <code class="code-wrap">
68
+ <div class="args-extended">
69
+ <%= job_desc['args']&.to_json %>
70
+ <%= job_desc['kwargs']&.to_json %>
71
+ </div>
72
+ </code>
73
+ </td>
74
+ </tr>
75
+ <% end %>
76
+ </table>
77
+ </div>
78
+ <% end %>
79
+
80
+ <%# Pending Tasks %>
38
81
  <header class="row">
39
82
  <div class="col-sm-5">
40
83
  <h3>
41
- <%= t('Tasks') %>
84
+ <%= t('Pending Tasks') %>
42
85
  </h3>
43
86
  </div>
44
87
  <%
@@ -166,6 +166,8 @@ module CanvasSync::JobBatches::Sidekiq
166
166
  @pid = params[:pid]
167
167
  @pool = CanvasSync::JobBatches::Pool.new(@pid)
168
168
 
169
+ @active_tasks = @pool.redis.hvals("#{@pool.redis_key}-active").map {|desc, score=nil| JSON.parse(desc) }
170
+
169
171
  @count = (params['count'] || 25).to_i
170
172
  @current_jobs_page, @total_jobs_size, @jobs = page("POOLID-#{@pool.pid}-jobs", params['job_page'], @count)
171
173
  @jobs = @jobs.map {|desc, score=nil| JSON.parse(desc)[0] }
@@ -1,3 +1,3 @@
1
1
  module CanvasSync
2
- VERSION = "0.19.0.beta1".freeze
2
+ VERSION = "0.19.0.beta3".freeze
3
3
  end