canvas_sync 0.17.32 → 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 +17 -0
- 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/version.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
|
@@ -453,6 +453,23 @@ module CanvasSync
|
|
453
453
|
end
|
454
454
|
end
|
455
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
|
+
|
456
473
|
def method_missing(method_name, *arguments, &block)
|
457
474
|
Batch.redis do |r|
|
458
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>
|
data/lib/canvas_sync/version.rb
CHANGED
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
|