canvas_sync 0.18.0.beta1 → 0.18.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: de4a872d4a40555407e9dd9e2ab4e10aabfe61a68e06be46caaface500d89358
4
- data.tar.gz: a79a7d11bdf1565662aab1832cc9cd664cc7e41b52e8586c57f579ef0b2f9f6a
3
+ metadata.gz: 98a15ade4fa059c8a6641a20f560c32a81ff3ef066a46c7e79bd2182e25bed18
4
+ data.tar.gz: 9d08800f6bdc163b40e727ae97ebb7baf82abe47d585e252860c6e31cf812144
5
5
  SHA512:
6
- metadata.gz: 0b50db7fb0d71fc8e707793e4ba3275407e2a8e3e00d6991d5e233c1aeb479859e9d6a36206b77e7d52797f4dd422ae1ab0a4c8d249767d885587b2616368eba
7
- data.tar.gz: 61bb66d592d83b9e263d443328a05d32a1bd17e551a87cbd59c68821820bf471c80fa708719edc35dbbbe6530fa0496d2e4c99ee70ddb7836195412b3e8687d2
6
+ metadata.gz: d603c64d9ca24d974913f6c422c9a0f3f6a9eecb6486a0d6f8fc26a57bffaa1c40971ec56bd54adb1a187896307accc2e7910947db90bd79d3737d6d7d773c76
7
+ data.tar.gz: 5a8d948e840c39e1e47647d0f8c4dcd46057349abf9818ce9acb04879408c3ee37961fab8fa1391832f7f35d1e099eba1c627c211370316eda564fd65e1f5430
@@ -155,6 +155,11 @@ module CanvasSync::Concerns
155
155
  end
156
156
 
157
157
  apply_block = options[:process_response]
158
+
159
+ if self.class.column_names.include?("canvas_synced_at")
160
+ self.canvas_synced_at = mapped_params[:canvas_synced_at] = DateTime.now
161
+ end
162
+
158
163
  if apply_block.present?
159
164
  case apply_block.arity
160
165
  when 1
@@ -0,0 +1,11 @@
1
+ module CanvasSync::Concerns
2
+ module AutoRelations
3
+ extend ActiveSupport::Concern
4
+
5
+ # CanvasSync::Record.define_feature self, default: true
6
+
7
+ included do
8
+
9
+ end
10
+ end
11
+ end
@@ -101,7 +101,19 @@ module CanvasSync
101
101
 
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
- klass.import(columns, rows, options)
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],
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)
114
+ end
115
+
116
+ result
105
117
  end
106
118
 
107
119
  # This method generates SQL that looks like:
@@ -118,9 +130,13 @@ module CanvasSync
118
130
  columns_str = columns.map { |c| "#{klass.quoted_table_name}.#{c}" }.join(", ")
119
131
  excluded_str = columns.map { |c| "EXCLUDED.#{c}" }.join(", ")
120
132
  condition_sql = "(#{columns_str}) IS DISTINCT FROM (#{excluded_str})"
121
- if klass.column_names.include?("updated_at") && report_start
133
+
134
+ if klass.column_names.include?("canvas_synced_at") && report_start
135
+ condition_sql += " AND #{klass.quoted_table_name}.canvas_synced_at < '#{report_start}'"
136
+ elsif klass.column_names.include?("updated_at") && report_start
122
137
  condition_sql += " AND #{klass.quoted_table_name}.updated_at < '#{report_start}'"
123
138
  end
139
+
124
140
  condition_sql
125
141
  end
126
142
 
@@ -100,6 +100,10 @@ module CanvasSync
100
100
 
101
101
  included do
102
102
  define_model_callbacks :sync_import
103
+
104
+ if column_names.include?("canvas_sync_batch_id")
105
+ belongs_to :canvas_sync_batch, foreign_key: :canvas_sync_batch_id, class_name: "CanvasSync::SyncBatch", optional: true
106
+ end
103
107
  end
104
108
  end
105
109
  end
@@ -1,3 +1,3 @@
1
1
  module CanvasSync
2
- VERSION = "0.18.0.beta1".freeze
2
+ VERSION = "0.18.1".freeze
3
3
  end
data/lib/canvas_sync.rb CHANGED
@@ -204,7 +204,7 @@ module CanvasSync
204
204
  end
205
205
 
206
206
  current_chain.insert(
207
- generate_provisioning_jobs(models, options, only_split: ['users'])
207
+ generate_provisioning_jobs(models, options)
208
208
  )
209
209
 
210
210
  ###############################
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.18.0.beta1
4
+ version: 0.18.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Collings
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-27 00:00:00.000000000 Z
11
+ date: 2023-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -414,6 +414,7 @@ files:
414
414
  - lib/canvas_sync/concerns/ability_helper.rb
415
415
  - lib/canvas_sync/concerns/account/ancestry.rb
416
416
  - lib/canvas_sync/concerns/api_syncable.rb
417
+ - lib/canvas_sync/concerns/auto_relations.rb
417
418
  - lib/canvas_sync/concerns/legacy_columns.rb
418
419
  - lib/canvas_sync/concerns/role/base.rb
419
420
  - lib/canvas_sync/concerns/sync_mapping.rb
@@ -744,9 +745,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
744
745
  version: '0'
745
746
  required_rubygems_version: !ruby/object:Gem::Requirement
746
747
  requirements:
747
- - - ">"
748
+ - - ">="
748
749
  - !ruby/object:Gem::Version
749
- version: 1.3.1
750
+ version: '0'
750
751
  requirements: []
751
752
  rubygems_version: 3.1.6
752
753
  signing_key: