canvas_sync 0.20.0 → 0.20.1

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: 64eb8c4553c0f0bc3d4c67d934c1fa50d59d0dff7fe5907bf84697b48a7e26d8
4
- data.tar.gz: 78acaecd3238bed5e840d3508a62addce82b8a56913ce672326d758f425eeae8
3
+ metadata.gz: 6d62d3319fd41f63dfadc619b59f28949b9e418f4017c0ca395ba98f62cea3a5
4
+ data.tar.gz: 789f76fc7c75a901a93e841fe1d883c635af40e1772191e30682e1837d92ca7e
5
5
  SHA512:
6
- metadata.gz: '086155981aa48b2b1bebe0b9e29b441211424399f09ce66e958d896f2f0c5f375b409d11c156b0f6bacbc229d61c6f30046113f4a953a30e6a82f6714671f598'
7
- data.tar.gz: 35b520ee37d2d5c74939a3e1c12374722a1e9eec81ed703a68af83e7ee1af5993987fe415dcc6c75fe413a96da65138ee1228a92ca22c2bbcbff87553a192990
6
+ metadata.gz: 373e4d1f08b87e585620625aa0fd15fd153fbd277b8ee81f195333a0fbc7e9e2b24aa558d63e06b9b71bbe9cbffa2f7f10f3a5b7c7a82f33566b515762356cc2
7
+ data.tar.gz: 856f8387e65df480460780a881d20764fce8dc7c78878940ba46f6b58cf6012be83cbb824c3cc5dd1c995b798a41b35492d9ab77c9194332a0748ace9dbca608
@@ -1,4 +1,5 @@
1
1
  begin
2
+ require "panda_pal"
2
3
  require "panda_pal/concerns/ability_helper"
3
4
  rescue LoadError
4
5
  end
@@ -102,15 +102,24 @@ module CanvasSync
102
102
  options = { validate: false, on_duplicate_key_update: update_conditions }.merge(import_args)
103
103
  options.delete(:on_duplicate_key_update) if options.key?(:on_duplicate_key_ignore)
104
104
 
105
- result = klass.import(columns, rows, options)
106
-
107
- global_updates = {
108
- canvas_synced_at: DateTime.now,
109
- canvas_sync_batch_id: JobBatches::Batch.current_context[:sync_batch_id],
105
+ result = nil
106
+ callback_env = {
107
+ batch: rows,
108
+ import_result: nil,
109
+ import_options: options,
110
110
  }
111
- global_updates.slice!(*klass.column_names.map(&:to_sym))
112
- if global_updates.present? && result.ids.present?
113
- klass.where(id: result.ids).update_all(global_updates)
111
+ ClassCallbackExecutor.run_if_defined(klass, :sync_batch_import, env: callback_env) do
112
+ result = klass.import(columns, rows, options)
113
+ callback_env[:import_result] = result
114
+
115
+ global_updates = {
116
+ canvas_synced_at: DateTime.now,
117
+ canvas_sync_batch_id: JobBatches::Batch.current_context[:sync_batch_id],
118
+ }
119
+ global_updates.slice!(*klass.column_names.map(&:to_sym))
120
+ if global_updates.present? && result.ids.present?
121
+ klass.where(id: result.ids).update_all(global_updates)
122
+ end
114
123
  end
115
124
 
116
125
  result
@@ -100,6 +100,7 @@ module CanvasSync
100
100
 
101
101
  included do
102
102
  define_model_callbacks :sync_import
103
+ define_model_callbacks :sync_batch_import
103
104
 
104
105
  col_names = column_names rescue []
105
106
 
@@ -1,3 +1,3 @@
1
1
  module CanvasSync
2
- VERSION = "0.20.0".freeze
2
+ VERSION = "0.20.1".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.20.0
4
+ version: 0.20.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Instructure CustomDev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-24 00:00:00.000000000 Z
11
+ date: 2024-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails