canvas_sync 0.17.29 → 0.17.32

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: 32eaa6fa25c776f85402a9b3fb36e20f69d8954106cca5759db80ee01298b5a5
4
- data.tar.gz: 9d2b05d16d6770cbe3b0e4053e5c22c01f416bc61350a14131c509978d9305d5
3
+ metadata.gz: ac101dc1c7a2d590408677aac25218ac20b762d993413c57ae9f8164b50fb3ad
4
+ data.tar.gz: c1d4785903974a78e8efc0612e5b36b0c342c6fb8bcfb615616c1e6002cb2186
5
5
  SHA512:
6
- metadata.gz: 1abd4a0de86b2f22b8f131750533c23507b3b0d354d24a4cd645e5bf368863561e386a2165ac046444fb2b86ca5114ef0de7c7fb45979eb780ea5d01640d9ab9
7
- data.tar.gz: a6f794c96ec97e3e39090421d4c339b3afb8d47024332a87b90324b17e2e13c3bc56455c781d0a95c1d391d3b84a08059d534792344b357bee14adccff0109d2
6
+ metadata.gz: 61f0685f874a9476d8130923b191e7ee1389fcf1cd7374f7b482c11c1e073b30a69796f43b02894cfd37800f7d2240e52d5e48291e8b0f8f8c3698d4f3e84938
7
+ data.tar.gz: d2a76163cf0a26ba32a96811c1d9e5ac63b6cc7bb23255a27416562e71bd25ee7ae1d57c0d8b21c8043701c9f76eed219469cf48c82883d68d403f938d4f6b0a
@@ -28,7 +28,7 @@ module CanvasSync
28
28
 
29
29
  delegate :redis, to: :class
30
30
 
31
- BID_EXPIRE_TTL = 2_592_000
31
+ BID_EXPIRE_TTL = 90.days.to_i
32
32
  SCHEDULE_CALLBACK = RedisScript.new(Pathname.new(__FILE__) + "../schedule_callback.lua")
33
33
  BID_HIERARCHY = RedisScript.new(Pathname.new(__FILE__) + "../hier_batch_ids.lua")
34
34
 
@@ -101,6 +101,8 @@ module CanvasSync
101
101
  r.hincrby("BID-#{parent_bid}", "children", 1)
102
102
  r.expire("BID-#{parent_bid}", BID_EXPIRE_TTL)
103
103
  r.zadd("BID-#{parent_bid}-bids", created_at, bid)
104
+ else
105
+ r.zadd("BID-ROOT-bids", created_at, bid)
104
106
  end
105
107
  end
106
108
 
@@ -242,7 +244,7 @@ module CanvasSync
242
244
  _, pending, failed, children, complete, parent_bid = redis do |r|
243
245
  return unless r.exists?("BID-#{bid}")
244
246
 
245
- r.multi do
247
+ r.multi do |r|
246
248
  r.sadd("BID-#{bid}-failed", jid)
247
249
 
248
250
  r.hincrby("BID-#{bid}", "pending", 0)
@@ -260,29 +262,19 @@ module CanvasSync
260
262
  end
261
263
  end
262
264
 
265
+ # Dead jobs are a Sidekiq feature.
266
+ # If this is called for a job, process_failed_job was also called
263
267
  def process_dead_job(bid, jid)
264
- _, failed, children, complete, parent_bid = redis do |r|
268
+ _, dead_count = redis do |r|
265
269
  return unless r.exists?("BID-#{bid}")
266
270
 
267
- r.multi do
271
+ r.multi do |r|
268
272
  r.sadd("BID-#{bid}-dead", jid)
269
-
270
273
  r.scard("BID-#{bid}-dead")
271
- r.hincrby("BID-#{bid}", "children", 0)
272
- r.scard("BID-#{bid}-batches-complete")
273
- r.hget("BID-#{bid}", "parent_bid")
274
-
275
274
  r.expire("BID-#{bid}-dead", BID_EXPIRE_TTL)
276
275
  end
277
276
  end
278
277
 
279
- if parent_bid
280
- redis.multi do
281
- r.sadd("BID-#{parent_bid}-dead", jid)
282
- r.expire("BID-#{parent_bid}-dead", BID_EXPIRE_TTL)
283
- end
284
- end
285
-
286
278
  enqueue_callbacks(:death, bid)
287
279
  end
288
280
 
@@ -290,7 +282,7 @@ module CanvasSync
290
282
  _, failed, pending, children, complete, success, parent_bid, keep_open = redis do |r|
291
283
  return unless r.exists?("BID-#{bid}")
292
284
 
293
- r.multi do
285
+ r.multi do |r|
294
286
  r.srem("BID-#{bid}-failed", jid)
295
287
 
296
288
  r.scard("BID-#{bid}-failed")
@@ -323,7 +315,7 @@ module CanvasSync
323
315
  return unless r.exists?(batch_key)
324
316
  return if r.hget(batch_key, 'keep_open') == 'true'
325
317
 
326
- r.multi do
318
+ r.multi do |r|
327
319
  r.smembers(callback_key)
328
320
  r.hget(batch_key, "callback_queue")
329
321
  r.hget(batch_key, "parent_bid")
@@ -379,6 +371,7 @@ module CanvasSync
379
371
  logger.debug {"Cleaning redis of batch #{bid}"}
380
372
  redis do |r|
381
373
  r.zrem("batches", bid)
374
+ r.zrem("BID-ROOT-bids", bid)
382
375
  r.unlink(
383
376
  "BID-#{bid}",
384
377
  "BID-#{bid}-callbacks-complete",
@@ -442,12 +435,8 @@ module CanvasSync
442
435
  class RedisProxy
443
436
  def multi(*args, &block)
444
437
  Batch.redis do |r|
445
- if block.arity == 1
446
- r.multi(*args) do
447
- block.call(r)
448
- end
449
- else
450
- r.multi(*args, &block)
438
+ r.multi(*args) do |r|
439
+ block.call(r)
451
440
  end
452
441
  end
453
442
  end
@@ -69,7 +69,7 @@ module CanvasSync
69
69
  # This is a callback for a callback. In this case we need to check if we should cleanup the original bid.
70
70
  origin_bid = opts['origin']['for_bid']
71
71
  _, pending, success_ran = Batch.redis do |r|
72
- r.multi do
72
+ r.multi do |r|
73
73
  r.srem("BID-#{origin_bid}-pending_callbacks", opts['origin']['event'])
74
74
  r.scard("BID-#{origin_bid}-pending_callbacks")
75
75
  r.hget("BID-#{origin_bid}", "success")
@@ -88,7 +88,7 @@ module CanvasSync
88
88
  return unless parent_bid
89
89
 
90
90
  _, _, success, _, _, complete, pending, children, success, failure = Batch.redis do |r|
91
- r.multi do
91
+ r.multi do |r|
92
92
  r.sadd("BID-#{parent_bid}-batches-success", bid)
93
93
  r.expire("BID-#{parent_bid}-batches-success", Batch::BID_EXPIRE_TTL)
94
94
  r.scard("BID-#{parent_bid}-batches-success")
@@ -116,7 +116,7 @@ module CanvasSync
116
116
 
117
117
  def complete(bid, status, parent_bid)
118
118
  pending, children, success = Batch.redis do |r|
119
- r.multi do
119
+ r.multi do |r|
120
120
  r.hincrby("BID-#{bid}", "pending", 0)
121
121
  r.hincrby("BID-#{bid}", "children", 0)
122
122
  r.scard("BID-#{bid}-batches-success")
@@ -131,7 +131,7 @@ module CanvasSync
131
131
 
132
132
  Batch.logger.debug {"Finalize parent complete bid: #{parent_bid}"}
133
133
  _, _, complete, pending, children, failure = Batch.redis do |r|
134
- r.multi do
134
+ r.multi do |r|
135
135
  r.sadd("BID-#{parent_bid}-batches-complete", bid)
136
136
  r.sadd("BID-#{parent_bid}-batches-failed", bid)
137
137
  r.scard("BID-#{parent_bid}-batches-complete")
@@ -127,7 +127,7 @@ module CanvasSync
127
127
  return @hash_map[bid] if @hash_map.key?(bid)
128
128
 
129
129
  context_json, editable = Batch.redis do |r|
130
- r.multi do
130
+ r.multi do |r|
131
131
  r.hget("BID-#{bid}", "context")
132
132
  r.hget("BID-#{bid}", "allow_context_changes")
133
133
  end
@@ -18,7 +18,7 @@ module CanvasSync
18
18
  man_batch_id = SecureRandom.urlsafe_base64(10)
19
19
 
20
20
  Batch.redis do |r|
21
- r.multi do
21
+ r.multi do |r|
22
22
  r.hset("MNGBID-#{man_batch_id}", "root_bid", root_batch.bid)
23
23
  r.hset("MNGBID-#{man_batch_id}", "ordered", ordered)
24
24
  r.hset("MNGBID-#{man_batch_id}", "concurrency", concurrency)
@@ -87,7 +87,7 @@ module CanvasSync
87
87
 
88
88
  def self.perform_next_sequence_job(man_batch_id)
89
89
  root_bid, ordered = Batch.redis do |r|
90
- r.multi do
90
+ r.multi do |r|
91
91
  r.hget("MNGBID-#{man_batch_id}", "root_bid")
92
92
  r.hget("MNGBID-#{man_batch_id}", "ordered")
93
93
  end
@@ -94,16 +94,16 @@ module CanvasSync
94
94
  redis.hincrby(redis_key, "active_count", 0)
95
95
  end
96
96
 
97
- def pending_count
97
+ def pending_count(r = redis)
98
98
  jobs_key = "#{redis_key}-jobs"
99
99
  order = self.order || 'fifo'
100
100
  case order.to_sym
101
101
  when :fifo, :lifo
102
- redis.llen(jobs_key)
102
+ r.llen(jobs_key)
103
103
  when :random
104
- redis.scard(jobs_key)
104
+ r.scard(jobs_key)
105
105
  when :priority
106
- redis.zcard(jobs_key)
106
+ r.zcard(jobs_key)
107
107
  end
108
108
  end
109
109
 
@@ -114,9 +114,9 @@ module CanvasSync
114
114
  # Make sure this is loaded outside of the pipeline
115
115
  self.order
116
116
 
117
- redis.multi do
117
+ redis.multi do |r|
118
118
  r.hincrby(redis_key, "active_count", -1)
119
- self.pending_count
119
+ self.pending_count(r)
120
120
  end
121
121
  end
122
122
 
@@ -40,7 +40,7 @@ module CanvasSync
40
40
  def persist_bid_attr(attribute, value)
41
41
  if @initialized || @existing
42
42
  redis do |r|
43
- r.multi do
43
+ r.multi do |r|
44
44
  r.hset(redis_key, attribute, value)
45
45
  r.expire(redis_key, Batch::BID_EXPIRE_TTL)
46
46
  end
@@ -13,7 +13,7 @@ module CanvasSync::JobBatches::Sidekiq
13
13
 
14
14
  def drain_zset(key)
15
15
  items, _ = Batch.redis do |r|
16
- r.multi do
16
+ r.multi do |r|
17
17
  r.zrange(key, 0, -1)
18
18
  r.zremrangebyrank(key, 0, -1)
19
19
  end
@@ -10,6 +10,8 @@ require_relative "web/helpers"
10
10
  module CanvasSync::JobBatches::Sidekiq
11
11
  module Web
12
12
  DEV_MODE = (defined?(Rails) && !Rails.env.production?) || !!ENV["SIDEKIQ_WEB_TESTING"]
13
+ Sidekiq::WebHelpers::SAFE_QPARAMS << 'all_batches'
14
+ Sidekiq::WebHelpers::SAFE_QPARAMS << 'count'
13
15
 
14
16
  def self.registered(app) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
15
17
  app.helpers do
@@ -24,7 +26,9 @@ module CanvasSync::JobBatches::Sidekiq
24
26
 
25
27
  app.get "/batches" do
26
28
  @count = (params['count'] || 25).to_i
27
- @current_page, @total_size, @batches = page('batches', params['page'], @count)
29
+
30
+ source_key = params['all_batches'] ? "batches" : "BID-ROOT-bids"
31
+ @current_page, @total_size, @batches = page(source_key, params['page'], @count)
28
32
  @batches = @batches.map {|b, score| CanvasSync::JobBatches::Batch.new(b) }
29
33
 
30
34
  erb(get_template(:batches))
@@ -10,7 +10,7 @@ module CanvasSync
10
10
  def perform(options)
11
11
  super(
12
12
  "proserv_student_submissions_csv",
13
- merge_report_params(options, { include_all: options[:include_all] }, {}),
13
+ merge_report_params(options, { include_all: options[:include_all], enrollment_batch_size: options[:enrollment_batch_size] }, {}),
14
14
  CanvasSync::Processors::SubmissionsProcessor.to_s,
15
15
  {},
16
16
  )
@@ -22,7 +22,7 @@ module CanvasSync
22
22
  JobBatches::ManagedBatchJob.make_batch(jobs, ordered: false, concurrency: true) do |b|
23
23
  b.description = "TermBatchJob(#{term_id}) Root"
24
24
  b.context = local_context
25
- b.on(:success, "#{self.class.to_s}.batch_finished")
25
+ b.on(:success, "#{self.class.to_s}.batch_finished") unless options[:mark_synced] == false
26
26
  end
27
27
  end
28
28
  else
@@ -1,3 +1,3 @@
1
1
  module CanvasSync
2
- VERSION = "0.17.29".freeze
2
+ VERSION = "0.17.32".freeze
3
3
  end
@@ -5,7 +5,7 @@ RSpec.describe CanvasSync::Jobs::SyncSubmissionsJob do
5
5
  context "a term id is in the global_options" do
6
6
  it "enqueues a ReportStarter for the proserv_student_submissions_csv for the given term" do
7
7
  expect_any_instance_of(Bearcat::Client).to receive(:start_report)
8
- .with("self", "proserv_student_submissions_csv", { parameters: { enrollment_term_id: 1, include_all: nil } })
8
+ .with("self", "proserv_student_submissions_csv", { parameters: { enrollment_term_id: 1, include_all: nil, enrollment_batch_size: nil } })
9
9
  .and_return("id" => 1)
10
10
 
11
11
  expect(CanvasSync::Jobs::ReportChecker).to receive(:set).and_call_original