canvas_sync 0.17.23.beta2 → 0.17.23.beta7

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: 0d5da2edfe978cc9fec69714ce7a1bd90cce3977023478473a7999143e78df90
4
- data.tar.gz: 510f341eb1d090275b302e971a6f26c59e046da7699cfaee567a34c23ce751c8
3
+ metadata.gz: 4ffd1eae28ffc49cdba7673f1648fbf82853a57768697df38d2a100c05c7ab3f
4
+ data.tar.gz: 4ab9d6f8c7ce264b69fae4da982d16dfedf40e5b1d1f64fbfd40831f16465bdf
5
5
  SHA512:
6
- metadata.gz: 891a38e3bd240de7c5c248d14bc21f84bc1336a19fb1509e74769076d7059bc4e3a2b7b8764cafe3aba8b6127d2278241a30b8f78f0735467408c269710dab31
7
- data.tar.gz: fc71f424836699e98cfa39ee435e919e81cb9bcc12deef30f4597806746ec8047136efc180db31ad906dc309d62526584fbdd17db04d2fe7b9b7495402f869a9
6
+ metadata.gz: 9619fbc749887158498c00761798cd0b10018ce5962262f27c9ff69c0615c66ffe1ebfa004bdc2ca7374308e53598ee81175f2372e2cde69527ce4672c288626
7
+ data.tar.gz: a9459bd07489e9c68abd692977e6ca1bc01b06d7dd960560f85e7f38bff4240ac8334aff15b91fb7f7a84897c7fcbd828e623d3b098fa34126b1b4e9be255222
@@ -5,6 +5,15 @@
5
5
  # * https://github.com/influitive/apartment/issues/508
6
6
 
7
7
  Rails.application.config.after_initialize do
8
+ next unless defined?(Apartment)
9
+
10
+ # Newer versions of Apartment already solves this issue (and in a better way)
11
+ begin
12
+ require('apartment/version')
13
+ next if Gem::Version.new(Apartment::VERSION) >= Gem::Version.new('2.8.1')
14
+ rescue LoadError
15
+ end
16
+
8
17
  begin
9
18
  Rails.application.eager_load!
10
19
  ActiveRecord::Base.descendants.each do |model|
@@ -24,9 +24,11 @@ module CanvasSync::Concerns
24
24
  class Mapping
25
25
  attr_reader :map_def
26
26
 
27
- def initialize(map_def = {}, model: nil)
28
- @map_def = map_def
27
+ def initialize(map_def, model: nil)
29
28
  @model = model
29
+ @map_def = map_def
30
+ @map_def[:conflict_target] ||= []
31
+ @map_def[:report_columns] ||= {}
30
32
  end
31
33
 
32
34
  def self.normalize_model_name(model)
@@ -82,7 +84,7 @@ module CanvasSync::Concerns
82
84
  end
83
85
 
84
86
  def reset_links
85
- @map_def = {}
87
+ @map_def[:report_columns] = {}.with_indifferent_access
86
88
  end
87
89
 
88
90
  def unlink_column(key)
@@ -4,8 +4,6 @@ class CreateGradingPeriodGroups < ActiveRecord::Migration[5.1]
4
4
  def change
5
5
  create_table :grading_period_groups do |t|
6
6
  t.bigint :canvas_id, null: false
7
- t.bigint :canvas_course_id
8
- t.bigint :canvas_account_id
9
7
  t.string :title
10
8
  t.boolean :weighted
11
9
  t.boolean :display_totals_for_all_grading_periods
@@ -16,7 +14,5 @@ class CreateGradingPeriodGroups < ActiveRecord::Migration[5.1]
16
14
  end
17
15
 
18
16
  add_index :grading_period_groups, :canvas_id, unique: true
19
- add_index :grading_period_groups, :canvas_course_id
20
- add_index :grading_period_groups, :canvas_account_id
21
17
  end
22
18
  end
@@ -4,6 +4,4 @@ class GradingPeriodGroup < ApplicationRecord
4
4
  include CanvasSync::Record
5
5
 
6
6
  validates :canvas_id, uniqueness: true, presence: true
7
- belongs_to :course, primary_key: :canvas_id, foreign_key: :canvas_course_id, optional: true
8
- belongs_to :account, primary_key: :canvas_id, foreign_key: :canvas_account_id, optional: true
9
7
  end
@@ -6,6 +6,7 @@ class Term < ApplicationRecord
6
6
 
7
7
  validates :canvas_id, uniqueness: true, presence: true
8
8
  has_many :courses, foreign_key: :canvas_term_id, primary_key: :canvas_id
9
+ belongs_to :grading_period_group, primary_key: :canvas_id, foreign_key: :grading_period_group_id, optional: true
9
10
 
10
11
  api_syncable({
11
12
  canvas_id: :id,
@@ -9,7 +9,7 @@ module CanvasSync
9
9
  # will be started for each term in that scope. :models should be an array of
10
10
  # models to sync.
11
11
  def perform(options)
12
- CanvasSync.get_canvas_sync_client(batch_context).terms("self").all_pages!.each do |term_params|
12
+ CanvasSync.get_canvas_sync_client(batch_context).terms("self", workflow_state: ['all']).all_pages!.each do |term_params|
13
13
  if account_id = batch_context[:account_id]
14
14
  # These branches are primarily to support Legacy apps
15
15
  if Term.respond_to?(:create_or_update) && Term.method(:create_or_update).arity.abs == 2
@@ -457,12 +457,6 @@ grading_period_groups:
457
457
  grading_period_group_id:
458
458
  database_column_name: canvas_id
459
459
  type: integer
460
- canvas_course_id:
461
- database_column_name: canvas_course_id
462
- type: integer
463
- canvas_account_id:
464
- database_column_name: canvas_account_id
465
- type: integer
466
460
  title:
467
461
  database_column_name: title
468
462
  type: string
@@ -5,11 +5,11 @@ module CanvasSync
5
5
  # Base report processing class
6
6
  class ReportProcessor
7
7
  def mapping
8
- SyncMapping::Mapping.default_mappings
8
+ CanvasSync::Concerns::SyncMapping::Mapping.default_mappings
9
9
  end
10
10
 
11
11
  def mapping_for(model, key = nil)
12
- model.try(:get_sync_mapping, key) || mapping[key || SyncMapping::Mapping.normalize_model_name(model)]
12
+ model.try(:get_sync_mapping, key) || mapping[key || CanvasSync::Concerns::SyncMapping::Mapping.normalize_model_name(model)]
13
13
  end
14
14
 
15
15
  def do_bulk_import(report_file_path, model, options: {}, mapping_key: nil)
@@ -1,3 +1,3 @@
1
1
  module CanvasSync
2
- VERSION = "0.17.23.beta2".freeze
2
+ VERSION = "0.17.23.beta7".freeze
3
3
  end
data/lib/canvas_sync.rb CHANGED
@@ -179,7 +179,7 @@ module CanvasSync
179
179
  # These Models use the provisioning report, but are not term-scoped,
180
180
  # so we sync them outside of the term scoping to ensure work is not duplicated
181
181
  if term_scope.present?
182
- models -= (first_provisioning_models = models & ['users', 'pseudonyms', 'user_observers'])
182
+ models -= (first_provisioning_models = models & ['users', 'pseudonyms', 'user_observers', 'grading_periods', 'grading_period_groups'])
183
183
  current_chain.insert(generate_provisioning_jobs(first_provisioning_models, options))
184
184
  end
185
185
 
@@ -10,6 +10,4 @@ class GradingPeriodGroup < ApplicationRecord
10
10
  include CanvasSync::Record
11
11
 
12
12
  validates :canvas_id, uniqueness: true, presence: true
13
- belongs_to :course, primary_key: :canvas_id, foreign_key: :canvas_course_id, optional: true
14
- belongs_to :account, primary_key: :canvas_id, foreign_key: :canvas_account_id, optional: true
15
13
  end
@@ -12,6 +12,7 @@ class Term < ApplicationRecord
12
12
 
13
13
  validates :canvas_id, uniqueness: true, presence: true
14
14
  has_many :courses, foreign_key: :canvas_term_id, primary_key: :canvas_id
15
+ belongs_to :grading_period_group, primary_key: :canvas_id, foreign_key: :grading_period_group_id, optional: true
15
16
 
16
17
  api_syncable({
17
18
  canvas_id: :id,
@@ -10,8 +10,6 @@ class CreateGradingPeriodGroups < ActiveRecord::Migration[5.1]
10
10
  def change
11
11
  create_table :grading_period_groups do |t|
12
12
  t.bigint :canvas_id, null: false
13
- t.bigint :canvas_course_id
14
- t.bigint :canvas_account_id
15
13
  t.string :title
16
14
  t.boolean :weighted
17
15
  t.boolean :display_totals_for_all_grading_periods
@@ -22,7 +20,5 @@ class CreateGradingPeriodGroups < ActiveRecord::Migration[5.1]
22
20
  end
23
21
 
24
22
  add_index :grading_period_groups, :canvas_id, unique: true
25
- add_index :grading_period_groups, :canvas_course_id
26
- add_index :grading_period_groups, :canvas_account_id
27
23
  end
28
24
  end
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 2021_09_07_233331) do
13
+ ActiveRecord::Schema.define(version: 2021_10_01_184920) do
14
14
 
15
15
  # These are extensions that must be enabled in order to support this database
16
16
  enable_extension "plpgsql"
@@ -175,16 +175,12 @@ ActiveRecord::Schema.define(version: 2021_09_07_233331) do
175
175
 
176
176
  create_table "grading_period_groups", force: :cascade do |t|
177
177
  t.bigint "canvas_id", null: false
178
- t.bigint "canvas_course_id"
179
- t.bigint "canvas_account_id"
180
178
  t.string "title"
181
179
  t.boolean "weighted"
182
180
  t.boolean "display_totals_for_all_grading_periods"
183
181
  t.string "workflow_state"
184
182
  t.datetime "created_at", null: false
185
183
  t.datetime "updated_at", null: false
186
- t.index ["canvas_account_id"], name: "index_grading_period_groups_on_canvas_account_id"
187
- t.index ["canvas_course_id"], name: "index_grading_period_groups_on_canvas_course_id"
188
184
  t.index ["canvas_id"], name: "index_grading_period_groups_on_canvas_id", unique: true
189
185
  end
190
186