canvas_sync 0.17.30 → 0.17.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/canvas_sync/concerns/sync_mapping.rb +1 -1
- data/lib/canvas_sync/engine.rb +20 -16
- data/lib/canvas_sync/job_batches/batch.rb +21 -1
- data/lib/canvas_sync/job_batches/callback.rb +1 -1
- data/lib/canvas_sync/job_batches/pool.rb +4 -4
- data/lib/canvas_sync/job_batches/sidekiq/web/helpers.rb +1 -1
- data/lib/canvas_sync/job_batches/sidekiq/web/views/batch.erb +10 -0
- data/lib/canvas_sync/job_batches/sidekiq/web.rb +5 -1
- data/lib/canvas_sync/jobs/sync_submissions_job.rb +1 -1
- data/lib/canvas_sync/version.rb +1 -1
- data/spec/canvas_sync/jobs/sync_submissions_job_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8585726d4c1e8cf1627897ed3b7e8af68a76f86d3ea35b9ba3ac0b7eaa56ff9
|
4
|
+
data.tar.gz: 1318778a8bbaadb0f5069a1b9bfdb106f0ae2e8ed5124079a8e9d7c4583be359
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ef7f29ce974199f5f1f26d43e4827ee77d93245b7b1ac4339fd33d03cbce1f6707df45d97ea533f24c21a45678e22b75db611a5a770ef073bf70fd0f37aa797
|
7
|
+
data.tar.gz: cc8892a896e4950e251c202e39ad4f17f012d8a1d39e588201ff27d927cd7e9d7160836fd05fd6892838cc3466dda5fd3e840121392cdb86269c5908cf0b0cea
|
data/lib/canvas_sync/engine.rb
CHANGED
@@ -32,24 +32,28 @@ module CanvasSync
|
|
32
32
|
initializer :integrate_pandapal do
|
33
33
|
require 'panda_pal'
|
34
34
|
|
35
|
-
|
36
|
-
if PandaPal::Organization.respond_to?(:
|
37
|
-
PandaPal::Organization.
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
35
|
+
Rails.application.reloader.to_prepare do
|
36
|
+
if PandaPal::Organization.respond_to?(:scheduled_task)
|
37
|
+
if PandaPal::Organization.respond_to?(:define_setting)
|
38
|
+
PandaPal::Organization.define_setting(:canvas_sync, {
|
39
|
+
type: 'Hash',
|
40
|
+
required: false,
|
41
|
+
properties: {
|
42
|
+
job_log_retention: { **RETENTION_TYPE },
|
43
|
+
sync_batch_retention: { **RETENTION_TYPE },
|
44
|
+
}
|
45
|
+
})
|
46
|
+
end
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
48
|
+
unless PandaPal::Organization.task_scheduled?(:clean_canvas_sync_logs)
|
49
|
+
PandaPal::Organization.scheduled_task '0 0 3 * * *', :clean_canvas_sync_logs do
|
50
|
+
job_log_retention = ChronicDuration.parse(settings.dig(:canvas_sync, :job_log_retention) || '3 months', keep_zero: true).seconds.ago
|
51
|
+
JobLog.where('updated_at < ?', job_log_retention).delete_all
|
50
52
|
|
51
|
-
|
52
|
-
|
53
|
+
sync_batch_retention = ChronicDuration.parse(settings.dig(:canvas_sync, :sync_batch_retention) || '6 months', keep_zero: true).seconds.ago
|
54
|
+
SyncBatch.where('updated_at < ?', sync_batch_retention).delete_all
|
55
|
+
end
|
56
|
+
end
|
53
57
|
end
|
54
58
|
end
|
55
59
|
rescue LoadError
|
@@ -28,7 +28,7 @@ module CanvasSync
|
|
28
28
|
|
29
29
|
delegate :redis, to: :class
|
30
30
|
|
31
|
-
BID_EXPIRE_TTL =
|
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
|
|
@@ -369,6 +371,7 @@ module CanvasSync
|
|
369
371
|
logger.debug {"Cleaning redis of batch #{bid}"}
|
370
372
|
redis do |r|
|
371
373
|
r.zrem("batches", bid)
|
374
|
+
r.zrem("BID-ROOT-bids", bid)
|
372
375
|
r.unlink(
|
373
376
|
"BID-#{bid}",
|
374
377
|
"BID-#{bid}-callbacks-complete",
|
@@ -450,6 +453,23 @@ module CanvasSync
|
|
450
453
|
end
|
451
454
|
end
|
452
455
|
|
456
|
+
def uget(key)
|
457
|
+
Batch.redis do |r|
|
458
|
+
case r.type(key)
|
459
|
+
when 'string'
|
460
|
+
r.get(key)
|
461
|
+
when 'list'
|
462
|
+
r.lrange(key, 0, -1)
|
463
|
+
when 'hash'
|
464
|
+
r.hgetall(key)
|
465
|
+
when 'set'
|
466
|
+
r.smembers(key)
|
467
|
+
when 'zset'
|
468
|
+
r.smembers(key, 0, -1)
|
469
|
+
end
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
453
473
|
def method_missing(method_name, *arguments, &block)
|
454
474
|
Batch.redis do |r|
|
455
475
|
r.send(method_name, *arguments, &block)
|
@@ -27,7 +27,7 @@ module CanvasSync
|
|
27
27
|
|
28
28
|
if clazz && object = Object.const_get(clazz)
|
29
29
|
target = target == :instance ? object.new : object
|
30
|
-
if target.respond_to?(method)
|
30
|
+
if target.respond_to?(method, true)
|
31
31
|
target.send(method, status, opts)
|
32
32
|
else
|
33
33
|
Batch.logger.warn("Invalid callback method #{definition} - #{target.to_s} does not respond to #{method}")
|
@@ -44,7 +44,7 @@ module CanvasSync
|
|
44
44
|
wrapper.on(checkin_event, "#{self.class.to_s}.job_checked_in", pool_id: pid)
|
45
45
|
wrapper.jobs {}
|
46
46
|
|
47
|
-
job_desc = job_desc.
|
47
|
+
job_desc = job_desc.symbolize_keys
|
48
48
|
job_desc = job_desc.merge!(
|
49
49
|
job: job_desc[:job].to_s,
|
50
50
|
pool_wrapper_batch: wrapper.bid,
|
@@ -149,7 +149,7 @@ module CanvasSync
|
|
149
149
|
if current_count < limit
|
150
150
|
job_desc = pop_job_from_pool
|
151
151
|
if job_desc.present?
|
152
|
-
Batch.new(job_desc[
|
152
|
+
Batch.new(job_desc[:pool_wrapper_batch]).jobs do
|
153
153
|
ChainBuilder.enqueue_job(job_desc)
|
154
154
|
end
|
155
155
|
jobs_added += 1
|
@@ -170,7 +170,7 @@ module CanvasSync
|
|
170
170
|
def push_job_to_pool(job_desc)
|
171
171
|
jobs_key = "#{redis_key}-jobs"
|
172
172
|
# This allows duplicate jobs when a Redis Set is used
|
173
|
-
job_desc[
|
173
|
+
job_desc[:_pool_random_key_] = SecureRandom.urlsafe_base64(10)
|
174
174
|
job_json = JSON.unparse(ActiveJob::Arguments.serialize([job_desc]))
|
175
175
|
order = self.order
|
176
176
|
|
@@ -204,7 +204,7 @@ module CanvasSync
|
|
204
204
|
|
205
205
|
return nil unless job_json.present?
|
206
206
|
|
207
|
-
ActiveJob::Arguments.deserialize(JSON.parse(job_json))[0]
|
207
|
+
ActiveJob::Arguments.deserialize(JSON.parse(job_json))[0]&.symbolize_keys
|
208
208
|
end
|
209
209
|
|
210
210
|
def self.redis(&blk)
|
@@ -10,6 +10,16 @@
|
|
10
10
|
<th colspan="2" scope=row><%= t('Batch') %></td>
|
11
11
|
<td><%= @batch.bid %></td>
|
12
12
|
</tr>
|
13
|
+
<tr>
|
14
|
+
<th colspan="2" scope=row><%= t('Parent') %></td>
|
15
|
+
<td>
|
16
|
+
<% if @batch.parent_bid.present? %>
|
17
|
+
<a href="<%= root_path %>batches/<%= @batch.parent_bid %>"><%= @batch.parent_bid %></a>
|
18
|
+
<% else %>
|
19
|
+
ROOT
|
20
|
+
<% end %>
|
21
|
+
</td>
|
22
|
+
</tr>
|
13
23
|
<tr>
|
14
24
|
<th colspan="2" scope=row><%= t('Started') %></td>
|
15
25
|
<td><%= safe_relative_time(@batch.created_at.to_f) %></td>
|
@@ -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
|
-
|
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
|
)
|
data/lib/canvas_sync/version.rb
CHANGED
@@ -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
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canvas_sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.17.
|
4
|
+
version: 0.17.33
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nate Collings
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|