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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac101dc1c7a2d590408677aac25218ac20b762d993413c57ae9f8164b50fb3ad
4
- data.tar.gz: c1d4785903974a78e8efc0612e5b36b0c342c6fb8bcfb615616c1e6002cb2186
3
+ metadata.gz: e8585726d4c1e8cf1627897ed3b7e8af68a76f86d3ea35b9ba3ac0b7eaa56ff9
4
+ data.tar.gz: 1318778a8bbaadb0f5069a1b9bfdb106f0ae2e8ed5124079a8e9d7c4583be359
5
5
  SHA512:
6
- metadata.gz: 61f0685f874a9476d8130923b191e7ee1389fcf1cd7374f7b482c11c1e073b30a69796f43b02894cfd37800f7d2240e52d5e48291e8b0f8f8c3698d4f3e84938
7
- data.tar.gz: d2a76163cf0a26ba32a96811c1d9e5ac63b6cc7bb23255a27416562e71bd25ee7ae1d57c0d8b21c8043701c9f76eed219469cf48c82883d68d403f938d4f6b0a
6
+ metadata.gz: 0ef7f29ce974199f5f1f26d43e4827ee77d93245b7b1ac4339fd33d03cbce1f6707df45d97ea533f24c21a45678e22b75db611a5a770ef073bf70fd0f37aa797
7
+ data.tar.gz: cc8892a896e4950e251c202e39ad4f17f012d8a1d39e588201ff27d927cd7e9d7160836fd05fd6892838cc3466dda5fd3e840121392cdb86269c5908cf0b0cea
@@ -88,7 +88,7 @@ module CanvasSync::Concerns
88
88
  end
89
89
 
90
90
  def unlink_column(key)
91
- @map_def.delete(key)
91
+ @map_def[:report_columns].delete(key)
92
92
  end
93
93
 
94
94
  def link_column(m, type: nil, &blk)
@@ -32,24 +32,28 @@ module CanvasSync
32
32
  initializer :integrate_pandapal do
33
33
  require 'panda_pal'
34
34
 
35
- if PandaPal::Organization.respond_to?(:scheduled_task)
36
- if PandaPal::Organization.respond_to?(:define_setting)
37
- PandaPal::Organization.define_setting(:canvas_sync, {
38
- type: 'Hash',
39
- required: false,
40
- properties: {
41
- job_log_retention: { **RETENTION_TYPE },
42
- sync_batch_retention: { **RETENTION_TYPE },
43
- }
44
- })
45
- end
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
- PandaPal::Organization.scheduled_task '0 0 3 * * *', :clean_canvas_sync_logs do
48
- job_log_retention = ChronicDuration.parse(settings.dig(:canvas_sync, :job_log_retention) || '3 months', keep_zero: true).seconds.ago
49
- JobLog.where('updated_at < ?', job_log_retention).delete_all
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
- sync_batch_retention = ChronicDuration.parse(settings.dig(:canvas_sync, :sync_batch_retention) || '6 months', keep_zero: true).seconds.ago
52
- SyncBatch.where('updated_at < ?', sync_batch_retention).delete_all
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.with_indifferent_access
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['pool_wrapper_batch']).jobs do
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['_pool_random_key_'] = SecureRandom.urlsafe_base64(10)
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)
@@ -12,7 +12,7 @@ module CanvasSync::JobBatches::Sidekiq
12
12
  end
13
13
 
14
14
  def drain_zset(key)
15
- items, _ = Batch.redis do |r|
15
+ items, _ = CanvasSync::JobBatches::Batch.redis do |r|
16
16
  r.multi do |r|
17
17
  r.zrange(key, 0, -1)
18
18
  r.zremrangebyrank(key, 0, -1)
@@ -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>
@@ -1,3 +1,3 @@
1
1
  module CanvasSync
2
- VERSION = "0.17.32".freeze
2
+ VERSION = "0.17.33".freeze
3
3
  end
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.32
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-05-26 00:00:00.000000000 Z
11
+ date: 2022-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails