canvas_sync 0.17.36 → 0.17.38

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: 2bcfff804b06ecd1812adc2b4cc52ac50f925329cdfe196b1e734a7ab6f308f8
4
- data.tar.gz: c553b8bdab0ba265e6d81f254c7d7022392a90a01af1bd998a81bdb36948d2b7
3
+ metadata.gz: b77546f58b3db164d3121fecdfb6de07d708e46a7673d7abeee45682d5390b45
4
+ data.tar.gz: c4ca76da8b99d56c2a1d9db6f9ef9be793ee0f74ca3ef4f59ad494f67f8a596c
5
5
  SHA512:
6
- metadata.gz: 4e2ac201fb1645f14cc82f3e8dda29640c7b82cbf9ff35b07d82ad898c926d2436694d4eb48fed3f7f528df4a33529e59304978f229e72ce9d469cc0d794b674
7
- data.tar.gz: d6345cf78fe6f606d98d8aadfc0ab9e7ae9f7cfb4b3655fa274e7d74381b2ffb32295896569e13d79357a58254f365b1453cdeab98d543f855709b0072289da7
6
+ metadata.gz: e1e655a7e5a202dd13a80f650538c6576c2998a15e35334fda932cf4b49485ad0cf5be2de2e79458f71e317cd21380375876c5cc5b3d7c5858e6071468b4421f
7
+ data.tar.gz: c1f5c91a3f01429fc0f588240f83003e78a46d8de29ce64020b7c36d2c7d582cd4b6f66743ab4f6c2c0be443ae9f32650e48d35a36434a1bb85d2636d371b84c
@@ -5,6 +5,12 @@ module CanvasSync
5
5
  class Engine < ::Rails::Engine
6
6
  isolate_namespace CanvasSync
7
7
 
8
+ initializer "canvas_sync.serialze_symbols" do |app|
9
+ app.config.active_record.yaml_column_permitted_classes ||= []
10
+ app.config.active_record.yaml_column_permitted_classes |= [Symbol]
11
+ rescue
12
+ end
13
+
8
14
  initializer :append_migrations do |app|
9
15
  config.paths["db/migrate"].expanded.each do |expanded_path|
10
16
  app.config.paths["db/migrate"] << expanded_path
@@ -4,7 +4,6 @@ class CreateUsers < ActiveRecord::Migration[5.1]
4
4
  def change
5
5
  create_table :users do |t|
6
6
  t.bigint :canvas_id, null: false
7
- t.string :sis_id
8
7
  t.string :email
9
8
  t.string :first_name
10
9
  t.string :last_name
@@ -23,7 +23,14 @@ module CanvasSync
23
23
  end
24
24
  end
25
25
 
26
- def self.perform_in_batches(report_file_path, mapping, klass, conflict_target, import_args: {})
26
+ def self.perform_in_batches(report_file_path, raw_mapping, klass, conflict_target, import_args: {})
27
+ mapping = {}.with_indifferent_access
28
+ raw_mapping.each do |db_col, opts|
29
+ next if opts[:deprecated] && !klass.column_names.include?(db_col.to_s)
30
+
31
+ mapping[db_col] = opts
32
+ end
33
+
27
34
  csv_column_names = mapping.values.map { |value| value[:report_column].to_s }
28
35
  database_column_names = mapping.keys
29
36
 
@@ -1,6 +1,6 @@
1
1
  module CanvasSync
2
2
  module JobBatches
3
- class BaseJob < ActiveJob::Base
3
+ class BaseJob < ::ActiveJob::Base
4
4
 
5
5
  end
6
6
  end
@@ -26,7 +26,7 @@ module CanvasSync
26
26
 
27
27
  mapped_sub_jobs = sub_jobs.each_with_index.map do |j, i|
28
28
  j['_mngbid_index_'] = i # This allows duplicate jobs when a Redis Set is used
29
- j = ActiveJob::Arguments.serialize([j])
29
+ j = ::ActiveJob::Arguments.serialize([j])
30
30
  JSON.unparse(j)
31
31
  end
32
32
  if ordered
@@ -104,7 +104,7 @@ module CanvasSync
104
104
  return unless next_job_json.present?
105
105
 
106
106
  next_job = JSON.parse(next_job_json)
107
- next_job = ActiveJob::Arguments.deserialize(next_job)[0]
107
+ next_job = ::ActiveJob::Arguments.deserialize(next_job)[0]
108
108
 
109
109
  Batch.new(root_bid).jobs do
110
110
  Batch.new.tap do |batch|
@@ -171,7 +171,7 @@ module CanvasSync
171
171
  jobs_key = "#{redis_key}-jobs"
172
172
  # This allows duplicate jobs when a Redis Set is used
173
173
  job_desc[:_pool_random_key_] = SecureRandom.urlsafe_base64(10)
174
- job_json = JSON.unparse(ActiveJob::Arguments.serialize([job_desc]))
174
+ job_json = JSON.unparse(::ActiveJob::Arguments.serialize([job_desc]))
175
175
  order = self.order
176
176
 
177
177
  redis.multi do |r|
@@ -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]&.symbolize_keys
207
+ ::ActiveJob::Arguments.deserialize(JSON.parse(job_json))[0]&.symbolize_keys
208
208
  end
209
209
 
210
210
  def self.redis(&blk)
@@ -76,11 +76,21 @@ module CanvasSync
76
76
  end
77
77
 
78
78
  def self.is_activejob_job?(msg)
79
- return false unless defined?(ActiveJob)
79
+ return false unless defined?(::ActiveJob)
80
80
 
81
81
  msg['class'] == 'ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper' && (msg['wrapped'].to_s).constantize < JobBatches::ActiveJob::BatchAwareJob
82
82
  end
83
83
 
84
+ def self.switch_tenant(job)
85
+ if defined?(::Apartment)
86
+ ::Apartment::Tenant.switch(job['apartment'] || 'public') do
87
+ yield
88
+ end
89
+ else
90
+ yield
91
+ end
92
+ end
93
+
84
94
  def self.configure
85
95
  if defined?(::Sidekiq::Batch) && ::Sidekiq::Batch != JobBatches::Batch
86
96
  print "WARNING: Detected Sidekiq Pro or sidekiq-batch. CanvasSync JobBatches may not be fully compatible!"
@@ -104,19 +114,12 @@ module CanvasSync
104
114
  end
105
115
 
106
116
  config.death_handlers << ->(job, ex) do
107
- if is_activejob_job?(job)
108
- JobBatches::ActiveJob.handle_job_death(job["args"][0], ex)
109
- return
110
- end
111
-
112
- return unless job['bid'].present?
113
-
114
- if defined?(::Apartment)
115
- ::Apartment::Tenant.switch(job['apartment'] || 'public') do
117
+ switch_tenant(job) do
118
+ if is_activejob_job?(job)
119
+ JobBatches::ActiveJob.handle_job_death(job["args"][0], ex)
120
+ elsif job['bid'].present?
116
121
  ::Sidekiq::Batch.process_dead_job(job['bid'], job['jid'])
117
122
  end
118
- else
119
- ::Sidekiq::Batch.process_dead_job(job['bid'], job['jid'])
120
123
  end
121
124
  end
122
125
  end
@@ -7,6 +7,7 @@ users:
7
7
  user_id:
8
8
  database_column_name: sis_id
9
9
  type: string
10
+ deprecated: true
10
11
  email:
11
12
  database_column_name: email
12
13
  type: string
@@ -1,3 +1,3 @@
1
1
  module CanvasSync
2
- VERSION = "0.17.36".freeze
2
+ VERSION = "0.17.38".freeze
3
3
  end