canvas_sync 0.9.0 → 0.9.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: 61fa3f2a6f2ac74170f0eec3866bec23c662fbcce8a83e8a60ada2602818d693
4
- data.tar.gz: 1a29823275161bf0a6d4c0e100702d75126395a56e20b5b4fe355baeb8c08696
3
+ metadata.gz: 07facec35d45ba07ac771963dea85bca3dbe9c920101808305d5bc9440ae158e
4
+ data.tar.gz: 919af58a0762425c6c128460a57bfc562d89ee9fe07cec7d7bb2f5983ad9211f
5
5
  SHA512:
6
- metadata.gz: 4a555023f1f12e4b30717e790b9b1405e4e536d8061e068ba129f4a68dea45c612729561c961cb1fdcf2467366c6ca65700ea441bf138f9b7e92d61b3cc02d07
7
- data.tar.gz: 431d583c39bdd9d5d04de46a02f1c2a65ad177b2767168d6e8ac1bb577584c0a5ca45ef5ba53ecd505b0f0accea28d437ae6c29dcb2f1f4b640a692e5200d944
6
+ metadata.gz: c88b2b03e0f74fa473d69c4665012e6f11755d2434ce47b81c443ca527ea11384f9573519931c3f5f1e197231bb2a6468c067745105e25c885d5cd89372a4f47
7
+ data.tar.gz: 6fa4ad837efdf6647f76f7451f749e4368f82fcb42661e9f834bb2b968ab5e0fdb4c19bfcdd484046ef23bfcbb03e399f8483e95124f9d72a8fe32dc5de332ec
@@ -155,69 +155,66 @@ module CanvasSync
155
155
  # @param account_id [Integer, nil] This optional parameter can be used if your Term creation and
156
156
  # canvas_sync_client methods require an account ID.
157
157
  # @return [Hash]
158
- def default_provisioning_report_chain(models, term_scope=nil, legacy_support=false, account_id=nil) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/LineLength
158
+ def default_provisioning_report_chain(models, term_scope=nil, legacy_support=false, account_id=nil, options: {}) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/LineLength
159
+ return unless models.present?
160
+ models.map! &:to_s
159
161
  term_scope = term_scope.to_s if term_scope
162
+ options = options.with_indifferent_access
163
+
164
+ model_job_map = {
165
+ terms: CanvasSync::Jobs::SyncTermsJob,
166
+ users: CanvasSync::Jobs::SyncUsersJob,
167
+ roles: CanvasSync::Jobs::SyncRolesJob,
168
+ admins: CanvasSync::Jobs::SyncAdminsJob,
169
+
170
+ assignments: CanvasSync::Jobs::SyncAssignmentsJob,
171
+ submissions: CanvasSync::Jobs::SyncSubmissionsJob,
172
+ assignment_groups: CanvasSync::Jobs::SyncAssignmentGroupsJob,
173
+ context_modules: CanvasSync::Jobs::SyncContextModulesJob,
174
+ context_module_items: CanvasSync::Jobs::SyncContextModuleItemsJob,
175
+ }.with_indifferent_access
176
+
177
+ jobs = []
178
+ try_add_model_job = ->(model) {
179
+ return unless models.include?(model)
180
+ jobs.push(job: model_job_map[model].to_s, options: options[model] || {})
181
+ models -= [model]
182
+ }
160
183
 
161
184
  ##############################
162
185
  # Pre provisioning report jobs
163
186
  ##############################
164
187
 
165
188
  # Always sync Terms first
166
- pre_provisioning_jobs = [{ job: CanvasSync::Jobs::SyncTermsJob.to_s, options: {} }]
189
+ models.unshift('terms') unless models.include?('terms')
190
+ try_add_model_job.call('terms')
167
191
 
168
192
  # Users, roles, and admins are synced before provisioning because they cannot be scoped to term
169
- if models.include?("users") && term_scope.present?
170
- pre_provisioning_jobs.push(job: CanvasSync::Jobs::SyncUsersJob.to_s, options: {})
171
- models -= ["users"]
172
- end
173
-
174
- if models.include?("roles")
175
- pre_provisioning_jobs.push(job: CanvasSync::Jobs::SyncRolesJob.to_s, options: {})
176
- models -= ["roles"]
177
- end
193
+ try_add_model_job.call('users') if term_scope.present?
194
+ try_add_model_job.call('roles')
195
+ try_add_model_job.call('admins')
178
196
 
179
- if models.include?("admins")
180
- pre_provisioning_jobs.push(job: CanvasSync::Jobs::SyncAdminsJob.to_s, options: {})
181
- models -= ["admins"]
182
- end
197
+ pre_provisioning_jobs = jobs
198
+ jobs = []
183
199
 
184
200
  ###############################
185
201
  # Post provisioning report jobs
186
202
  ###############################
187
203
 
188
- post_provisioning_jobs = []
189
-
190
- if models.include?("assignments")
191
- post_provisioning_jobs.push(job: CanvasSync::Jobs::SyncAssignmentsJob.to_s, options: {})
192
- models -= ["assignments"]
193
- end
194
-
195
- if models.include?("submissions")
196
- post_provisioning_jobs.push(job: CanvasSync::Jobs::SyncSubmissionsJob.to_s, options: {})
197
- models -= ["submissions"]
198
- end
199
-
200
- if models.include?("assignment_groups")
201
- post_provisioning_jobs.push(job: CanvasSync::Jobs::SyncAssignmentGroupsJob.to_s, options: {})
202
- models -= ["assignment_groups"]
203
- end
204
-
205
- if models.include?("context_modules")
206
- post_provisioning_jobs.push(job: CanvasSync::Jobs::SyncContextModulesJob.to_s, options: {})
207
- models -= ["context_modules"]
208
- end
204
+ try_add_model_job.call('assignments')
205
+ try_add_model_job.call('submissions')
206
+ try_add_model_job.call('assignment_groups')
207
+ try_add_model_job.call('context_modules')
208
+ try_add_model_job.call('context_module_items')
209
209
 
210
- if models.include?("context_module_items")
211
- post_provisioning_jobs.push(job: CanvasSync::Jobs::SyncContextModuleItemsJob.to_s, options: {})
212
- models -= ["context_module_items"]
213
- end
210
+ post_provisioning_jobs = jobs
214
211
 
215
- provisioning_job = {
212
+ jobs = pre_provisioning_jobs
213
+ jobs += Array.wrap({
216
214
  job: CanvasSync::Jobs::SyncProvisioningReportJob.to_s,
217
215
  options: { term_scope: term_scope, models: models },
218
- }
219
-
220
- jobs = pre_provisioning_jobs + Array.wrap(provisioning_job) + post_provisioning_jobs
216
+ }) if models.present?
217
+ jobs += post_provisioning_jobs
221
218
 
222
219
  global_options = { legacy_support: legacy_support }
223
220
  global_options[:account_id] = account_id if account_id.present?
@@ -8,12 +8,10 @@ module CanvasSync
8
8
  #
9
9
  # @param job_chain [Hash]
10
10
  # @param options [Hash]
11
- def perform(job_chain, _options)
12
- report_params = if job_chain[:global_options][:canvas_term_id].present?
13
- { "parameters[enrollment_term_id]" => job_chain[:global_options][:canvas_term_id] }
14
- else
15
- {}
16
- end
11
+ def perform(job_chain, options)
12
+ report_params = {}
13
+ report_params["parameters[enrollment_term_id]"] = job_chain[:global_options][:canvas_term_id] if job_chain[:global_options][:canvas_term_id].present?
14
+ report_params["parameters[include_all]"] = true if options[:include_all]
17
15
 
18
16
  super(
19
17
  job_chain,
@@ -1,3 +1,3 @@
1
1
  module CanvasSync
2
- VERSION = "0.9.0".freeze
2
+ VERSION = "0.9.1".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canvas_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Collings