canvas_sync 0.18.0.beta1 → 0.18.0.beta2

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: e8e85a06016546795344ff896342c54b8c3ec40dbd0568473bd0e4dc899c17d3
4
+ data.tar.gz: d2b566f00eb432b73fb8f47d70d1a88233c461ada010c374f677fcb2cde1a0aa
5
5
  SHA512:
6
- metadata.gz: 0b50db7fb0d71fc8e707793e4ba3275407e2a8e3e00d6991d5e233c1aeb479859e9d6a36206b77e7d52797f4dd422ae1ab0a4c8d249767d885587b2616368eba
7
- data.tar.gz: 61bb66d592d83b9e263d443328a05d32a1bd17e551a87cbd59c68821820bf471c80fa708719edc35dbbbe6530fa0496d2e4c99ee70ddb7836195412b3e8687d2
6
+ metadata.gz: bd4fdb11e3a79d796d18b908e100130ffaf503d060e00a5a8fb0cd249c70c3cbb5caf4fbf734ebf77c732c9640c361af5577df9c41431a9dc3ab3f7689852243
7
+ data.tar.gz: 63e5afb3933e8659cb3e263f2ace1ee6cdd2f344da9e439c9b44ac3f32c45c92935ce4c6f12d3966c7a2547b09a8bad8481c1706ebb34df7e0414bbe56a33fe1
@@ -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.0.beta2".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.18.0.beta1
4
+ version: 0.18.0.beta2
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-03-29 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