canvas_sync 0.17.28 → 0.17.31

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: 8359f6a5054489357a480d15019981f0ade50a145f714bcbd2274c6570689316
4
- data.tar.gz: c98c3d8ecda4291e162e31d7c4dfdf9ddff65763f0bb7c345006585f53894cf4
3
+ metadata.gz: '09cebb9b63254bcdf9e96ae0133d882fcf800ad405f6d53080793e8f3f0c052f'
4
+ data.tar.gz: 40d27ea858ac931d006ccbab54f7ee1b725166ad3fec4ecb369f6e3f0fa611f1
5
5
  SHA512:
6
- metadata.gz: 4ce90338e8e3751fd5767a09eaaf89e733532ffa59df5569bf908930929f34d5167bc01e2637a5eef6ba5ef515c2e6410cc17ce757542b4d0620bb08bd03fd38
7
- data.tar.gz: e4456ad37bbf87b63a495d041f038ad6ece797b59c11d19cd7028a030aef452281105f2c53ab56bef3b4cf515f838366874b56838c87936d113c3cacf5570771
6
+ metadata.gz: de38e11de998bef7cca15c875d63b29984d2cdf4dd90436854484e5686c5aca4eb249fd864e24b66d532afcba63b3f7ddb62c5e5abf55d1e2c621fa6cb566af7
7
+ data.tar.gz: 8493bc7a6f100da697840f65aeaceacbacc95c224aa53c66129e19d5a88d61b1f59202252ac80b2e8d42fc4661f974b30bd1825b448e58b477ce9e33f71a9f2c
@@ -242,7 +242,7 @@ module CanvasSync
242
242
  _, pending, failed, children, complete, parent_bid = redis do |r|
243
243
  return unless r.exists?("BID-#{bid}")
244
244
 
245
- r.multi do
245
+ r.multi do |r|
246
246
  r.sadd("BID-#{bid}-failed", jid)
247
247
 
248
248
  r.hincrby("BID-#{bid}", "pending", 0)
@@ -260,29 +260,19 @@ module CanvasSync
260
260
  end
261
261
  end
262
262
 
263
+ # Dead jobs are a Sidekiq feature.
264
+ # If this is called for a job, process_failed_job was also called
263
265
  def process_dead_job(bid, jid)
264
- _, failed, children, complete, parent_bid = redis do |r|
266
+ _, dead_count = redis do |r|
265
267
  return unless r.exists?("BID-#{bid}")
266
268
 
267
- r.multi do
269
+ r.multi do |r|
268
270
  r.sadd("BID-#{bid}-dead", jid)
269
-
270
271
  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
272
  r.expire("BID-#{bid}-dead", BID_EXPIRE_TTL)
276
273
  end
277
274
  end
278
275
 
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
276
  enqueue_callbacks(:death, bid)
287
277
  end
288
278
 
@@ -290,7 +280,7 @@ module CanvasSync
290
280
  _, failed, pending, children, complete, success, parent_bid, keep_open = redis do |r|
291
281
  return unless r.exists?("BID-#{bid}")
292
282
 
293
- r.multi do
283
+ r.multi do |r|
294
284
  r.srem("BID-#{bid}-failed", jid)
295
285
 
296
286
  r.scard("BID-#{bid}-failed")
@@ -323,7 +313,7 @@ module CanvasSync
323
313
  return unless r.exists?(batch_key)
324
314
  return if r.hget(batch_key, 'keep_open') == 'true'
325
315
 
326
- r.multi do
316
+ r.multi do |r|
327
317
  r.smembers(callback_key)
328
318
  r.hget(batch_key, "callback_queue")
329
319
  r.hget(batch_key, "parent_bid")
@@ -442,12 +432,8 @@ module CanvasSync
442
432
  class RedisProxy
443
433
  def multi(*args, &block)
444
434
  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)
435
+ r.multi(*args) do |r|
436
+ block.call(r)
451
437
  end
452
438
  end
453
439
  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,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
  )
@@ -20,9 +20,9 @@ module CanvasSync
20
20
  end
21
21
 
22
22
  JobBatches::ManagedBatchJob.make_batch(jobs, ordered: false, concurrency: true) do |b|
23
- b.description = "TermBatchJob(#{term.canvas_id}) Root"
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.28".freeze
2
+ VERSION = "0.17.31".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