canvas_sync 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/canvas_sync.rb +16 -15
  4. data/lib/canvas_sync/api_syncable.rb +4 -162
  5. data/lib/canvas_sync/class_callback_executor.rb +35 -0
  6. data/lib/canvas_sync/concerns/account/ancestry.rb +60 -0
  7. data/lib/canvas_sync/concerns/api_syncable.rb +189 -0
  8. data/lib/canvas_sync/concerns/legacy_columns.rb +34 -0
  9. data/lib/canvas_sync/generators/templates/models/account.rb +7 -1
  10. data/lib/canvas_sync/generators/templates/models/admin.rb +2 -1
  11. data/lib/canvas_sync/generators/templates/models/assignment.rb +2 -1
  12. data/lib/canvas_sync/generators/templates/models/assignment_group.rb +2 -1
  13. data/lib/canvas_sync/generators/templates/models/context_module.rb +2 -1
  14. data/lib/canvas_sync/generators/templates/models/context_module_item.rb +2 -1
  15. data/lib/canvas_sync/generators/templates/models/course.rb +3 -2
  16. data/lib/canvas_sync/generators/templates/models/enrollment.rb +2 -1
  17. data/lib/canvas_sync/generators/templates/models/role.rb +2 -1
  18. data/lib/canvas_sync/generators/templates/models/section.rb +2 -1
  19. data/lib/canvas_sync/generators/templates/models/submission.rb +2 -1
  20. data/lib/canvas_sync/generators/templates/models/term.rb +2 -1
  21. data/lib/canvas_sync/generators/templates/models/user.rb +2 -1
  22. data/lib/canvas_sync/importers/bulk_importer.rb +7 -1
  23. data/lib/canvas_sync/importers/legacy_importer.rb +4 -2
  24. data/lib/canvas_sync/job.rb +3 -1
  25. data/lib/canvas_sync/job_chain.rb +57 -0
  26. data/lib/canvas_sync/jobs/sync_accounts_job.rb +31 -0
  27. data/lib/canvas_sync/record.rb +9 -0
  28. data/lib/canvas_sync/version.rb +1 -1
  29. data/spec/canvas_sync/canvas_sync_spec.rb +14 -14
  30. data/spec/dummy/app/models/account.rb +7 -1
  31. data/spec/dummy/app/models/admin.rb +2 -1
  32. data/spec/dummy/app/models/assignment.rb +2 -1
  33. data/spec/dummy/app/models/assignment_group.rb +2 -1
  34. data/spec/dummy/app/models/context_module.rb +2 -1
  35. data/spec/dummy/app/models/context_module_item.rb +2 -1
  36. data/spec/dummy/app/models/course.rb +3 -2
  37. data/spec/dummy/app/models/enrollment.rb +2 -1
  38. data/spec/dummy/app/models/role.rb +2 -1
  39. data/spec/dummy/app/models/section.rb +2 -1
  40. data/spec/dummy/app/models/submission.rb +2 -1
  41. data/spec/dummy/app/models/term.rb +2 -1
  42. data/spec/dummy/app/models/user.rb +2 -1
  43. data/spec/dummy/config/application.rb +12 -1
  44. data/spec/dummy/config/database.yml +11 -11
  45. data/spec/dummy/config/environments/development.rb +3 -3
  46. data/spec/dummy/config/initializers/assets.rb +1 -1
  47. metadata +9 -2
@@ -7,11 +7,17 @@
7
7
 
8
8
 
9
9
  class Account < ApplicationRecord
10
- include CanvasSync::ApiSyncable
10
+ include CanvasSync::Record
11
+ include CanvasSync::Concerns::ApiSyncable
12
+ # include CanvasSync::Concerns::Account::Ancestry # Add support for the ancestry Gem
11
13
 
12
14
  validates :canvas_id, uniqueness: true, presence: true
13
15
 
14
16
  has_many :admins, primary_key: :canvas_id, foreign_key: :canvas_account_id
17
+ belongs_to :canvas_parent, class_name: 'Account', optional: true,
18
+ primary_key: :canvas_id, foreign_key: :canvas_parent_account_id
19
+ has_many :sub_accounts, class_name: 'Account',
20
+ primary_key: :canvas_id, foreign_key: :canvas_parent_account_id
15
21
 
16
22
  api_syncable({
17
23
  name: :name,
@@ -7,7 +7,8 @@
7
7
 
8
8
 
9
9
  class Admin < ApplicationRecord
10
- include CanvasSync::ApiSyncable
10
+ include CanvasSync::Record
11
+ include CanvasSync::Concerns::ApiSyncable
11
12
 
12
13
  validates :canvas_id, uniqueness: true, presence: true
13
14
  belongs_to :account, primary_key: :canvas_id, foreign_key: :canvas_account_id, optional: true
@@ -7,7 +7,8 @@
7
7
 
8
8
 
9
9
  class Assignment < ApplicationRecord
10
- include CanvasSync::ApiSyncable
10
+ include CanvasSync::Record
11
+ include CanvasSync::Concerns::ApiSyncable
11
12
 
12
13
  validates :canvas_id, uniqueness: true, presence: true
13
14
  belongs_to :context, polymorphic: true, optional: true, primary_key: :canvas_id, foreign_key: :canvas_context_id, foreign_type: :canvas_context_type
@@ -7,7 +7,8 @@
7
7
 
8
8
 
9
9
  class AssignmentGroup < ApplicationRecord
10
- include CanvasSync::ApiSyncable
10
+ include CanvasSync::Record
11
+ include CanvasSync::Concerns::ApiSyncable
11
12
 
12
13
  validates :canvas_id, uniqueness: true, presence: true
13
14
  belongs_to :course, primary_key: :canvas_id, foreign_key: :canvas_course_id, optional: true
@@ -10,7 +10,8 @@
10
10
  # 1 - Module is a reserved word in Rails and you can't call a model a Module
11
11
  # 2 - Canvas calls them ContextModules
12
12
  class ContextModule < ApplicationRecord
13
- include CanvasSync::ApiSyncable
13
+ include CanvasSync::Record
14
+ include CanvasSync::Concerns::ApiSyncable
14
15
 
15
16
  belongs_to :context, polymorphic: true, optional: true, primary_key: :canvas_id, foreign_key: :canvas_context_id, foreign_type: :canvas_context_type
16
17
  has_many :context_module_items, primary_key: :canvas_id, foreign_key: :canvas_context_module_id
@@ -7,7 +7,8 @@
7
7
 
8
8
 
9
9
  class ContextModuleItem < ApplicationRecord
10
- include CanvasSync::ApiSyncable
10
+ include CanvasSync::Record
11
+ include CanvasSync::Concerns::ApiSyncable
11
12
 
12
13
  belongs_to :context_module, primary_key: :canvas_id, foreign_key: :canvas_context_module_id, optional: true
13
14
  belongs_to :content, polymorphic: true, optional: true, primary_key: :canvas_id, foreign_key: :canvas_content_id, foreign_type: :canvas_content_type
@@ -7,7 +7,8 @@
7
7
 
8
8
 
9
9
  class Course < ApplicationRecord
10
- include CanvasSync::ApiSyncable
10
+ include CanvasSync::Record
11
+ include CanvasSync::Concerns::ApiSyncable
11
12
 
12
13
  validates :canvas_id, uniqueness: true, presence: true
13
14
  belongs_to :term, foreign_key: :canvas_term_id, primary_key: :canvas_id, optional: true
@@ -16,7 +17,7 @@ class Course < ApplicationRecord
16
17
  has_many :assignments, as: :context, primary_key: :canvas_id, foreign_key: :canvas_context_id, foreign_type: :canvas_context_type
17
18
  has_many :submissions, primary_key: :canvas_id, foreign_key: :canvas_course_id
18
19
  has_many :assignment_groups, primary_key: :canvas_id, foreign_key: :canvas_course_id
19
-
20
+
20
21
  api_syncable({
21
22
  sis_id: :sis_course_id,
22
23
  course_code: :course_code,
@@ -7,7 +7,8 @@
7
7
 
8
8
 
9
9
  class Enrollment < ApplicationRecord
10
- include CanvasSync::ApiSyncable
10
+ include CanvasSync::Record
11
+ include CanvasSync::Concerns::ApiSyncable
11
12
 
12
13
  validates :canvas_id, uniqueness: true, presence: true
13
14
  belongs_to :user, primary_key: :canvas_id, foreign_key: :canvas_user_id, optional: true
@@ -7,7 +7,8 @@
7
7
 
8
8
 
9
9
  class Role < ApplicationRecord
10
- include CanvasSync::ApiSyncable
10
+ include CanvasSync::Record
11
+ include CanvasSync::Concerns::ApiSyncable
11
12
 
12
13
  validates :canvas_id, uniqueness: true, presence: true
13
14
  has_many :admins, foreign_key: :canvas_role_id, primary_key: :canvas_id
@@ -7,7 +7,8 @@
7
7
 
8
8
 
9
9
  class Section < ApplicationRecord
10
- include CanvasSync::ApiSyncable
10
+ include CanvasSync::Record
11
+ include CanvasSync::Concerns::ApiSyncable
11
12
 
12
13
  validates :canvas_id, uniqueness: true, presence: true
13
14
  belongs_to :course, primary_key: :canvas_id, foreign_key: :canvas_course_id, optional: true
@@ -7,7 +7,8 @@
7
7
 
8
8
 
9
9
  class Submission < ApplicationRecord
10
- include CanvasSync::ApiSyncable
10
+ include CanvasSync::Record
11
+ include CanvasSync::Concerns::ApiSyncable
11
12
 
12
13
  validates :canvas_id, uniqueness: true, presence: true
13
14
  belongs_to :assignment, primary_key: :canvas_id, foreign_key: :canvas_assignment_id, optional: true
@@ -7,7 +7,8 @@
7
7
 
8
8
 
9
9
  class Term < ApplicationRecord
10
- include CanvasSync::ApiSyncable
10
+ include CanvasSync::Record
11
+ include CanvasSync::Concerns::ApiSyncable
11
12
 
12
13
  validates :canvas_id, uniqueness: true, presence: true
13
14
  has_many :courses, foreign_key: :canvas_term_id, primary_key: :canvas_id
@@ -7,7 +7,8 @@
7
7
 
8
8
 
9
9
  class User < ApplicationRecord
10
- include CanvasSync::ApiSyncable
10
+ include CanvasSync::Record
11
+ include CanvasSync::Concerns::ApiSyncable
11
12
 
12
13
  validates :canvas_id, uniqueness: true, presence: true
13
14
  has_many :enrollments, primary_key: :canvas_id, foreign_key: :canvas_user_id
@@ -1,6 +1,17 @@
1
1
  require File.expand_path('../boot', __FILE__)
2
2
 
3
- require 'rails/all'
3
+ require 'rails'
4
+ require 'active_record/railtie'
5
+ # require 'active_storage/engine'
6
+ require 'action_controller/railtie'
7
+ require 'action_view/railtie'
8
+ require 'action_mailer/railtie'
9
+ require 'active_job/railtie'
10
+ # require 'action_cable/engine'
11
+ # require 'action_mailbox/engine'
12
+ # require 'action_text/engine'
13
+ require 'rails/test_unit/railtie'
14
+ # require 'sprockets/railtie'
4
15
 
5
16
  Bundler.require(*Rails.groups)
6
17
  require "canvas_sync"
@@ -1,25 +1,25 @@
1
- # SQLite version 3.x
2
- # gem install sqlite3
3
- #
4
- # Ensure the SQLite 3 gem is defined in your Gemfile
5
- # gem 'sqlite3'
6
- #
1
+
7
2
  default: &default
8
3
  adapter: postgresql
9
- pool: 5
10
- timeout: 5000
4
+ encoding: unicode
5
+ # For details on connection pooling, see Rails configuration guide
6
+ # http://guides.rubyonrails.org/configuring.html#database-pooling
7
+ pool: <%= ENV.fetch("DB_POOL_SIZE", nil) || (ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i + 10) %>
8
+ username: <%= ENV.fetch("DB_USERNAME", "") %>
9
+ password: <%= ENV.fetch("DB_PASSWORD", "") %>
10
+ host: <%= ENV.fetch("DB_ADDRESS", "localhost") %>
11
11
 
12
12
  development:
13
13
  <<: *default
14
14
  database: canvas_sync_development
15
15
 
16
- # Warning: The database defined as "test" will be erased and
17
- # re-generated from your development database when you run "rake".
18
- # Do not set this db to the same as development or production.
19
16
  test:
20
17
  <<: *default
21
18
  database: canvas_sync_test
22
19
 
23
20
  production:
24
21
  <<: *default
22
+ host: <%= ENV.fetch('DB_ADDRESS', 'localhost') %>
25
23
  database: canvas_sync_production
24
+ username: <%= ENV.fetch("DB_USERNAME", "canvas_sync_specs_postgres_user") %>
25
+ password: <%= ENV.fetch("DB_PASSWORD", 'canvas_sync_specs_postgres_password') %>
@@ -25,16 +25,16 @@ Rails.application.configure do
25
25
  # Debug mode disables concatenation and preprocessing of assets.
26
26
  # This option may cause significant delays in view rendering with a large
27
27
  # number of complex assets.
28
- config.assets.debug = true
28
+ # config.assets.debug = true
29
29
 
30
30
  # Asset digests allow you to set far-future HTTP expiration dates on all assets,
31
31
  # yet still be able to expire them through the digest params.
32
- config.assets.digest = true
32
+ # config.assets.digest = true
33
33
 
34
34
  # Adds additional error checking when serving assets at runtime.
35
35
  # Checks for improperly declared sprockets dependencies.
36
36
  # Raises helpful error messages.
37
- config.assets.raise_runtime_errors = true
37
+ # config.assets.raise_runtime_errors = true
38
38
 
39
39
  # Raises error for missing translations
40
40
  # config.action_view.raise_on_missing_translations = true
@@ -1,7 +1,7 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
3
  # Version of your assets, change this if you want to expire all your assets.
4
- Rails.application.config.assets.version = '1.0'
4
+ # Rails.application.config.assets.version = '1.0'
5
5
 
6
6
  # Add additional assets to the asset load path
7
7
  # Rails.application.config.assets.paths << Emoji.images_path
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.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Collings
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-14 00:00:00.000000000 Z
11
+ date: 2020-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -322,6 +322,10 @@ files:
322
322
  - db/migrate/20190916154829_add_fork_count_to_canvas_sync_job_logs.rb
323
323
  - lib/canvas_sync.rb
324
324
  - lib/canvas_sync/api_syncable.rb
325
+ - lib/canvas_sync/class_callback_executor.rb
326
+ - lib/canvas_sync/concerns/account/ancestry.rb
327
+ - lib/canvas_sync/concerns/api_syncable.rb
328
+ - lib/canvas_sync/concerns/legacy_columns.rb
325
329
  - lib/canvas_sync/config.rb
326
330
  - lib/canvas_sync/engine.rb
327
331
  - lib/canvas_sync/generators/install_generator.rb
@@ -367,10 +371,12 @@ files:
367
371
  - lib/canvas_sync/importers/bulk_importer.rb
368
372
  - lib/canvas_sync/importers/legacy_importer.rb
369
373
  - lib/canvas_sync/job.rb
374
+ - lib/canvas_sync/job_chain.rb
370
375
  - lib/canvas_sync/jobs/fork_gather.rb
371
376
  - lib/canvas_sync/jobs/report_checker.rb
372
377
  - lib/canvas_sync/jobs/report_processor_job.rb
373
378
  - lib/canvas_sync/jobs/report_starter.rb
379
+ - lib/canvas_sync/jobs/sync_accounts_job.rb
374
380
  - lib/canvas_sync/jobs/sync_admins_job.rb
375
381
  - lib/canvas_sync/jobs/sync_assignment_groups_job.rb
376
382
  - lib/canvas_sync/jobs/sync_assignments_job.rb
@@ -391,6 +397,7 @@ files:
391
397
  - lib/canvas_sync/processors/provisioning_report_processor.rb
392
398
  - lib/canvas_sync/processors/report_processor.rb
393
399
  - lib/canvas_sync/processors/submissions_processor.rb
400
+ - lib/canvas_sync/record.rb
394
401
  - lib/canvas_sync/sidekiq_job.rb
395
402
  - lib/canvas_sync/version.rb
396
403
  - spec/canvas_sync/canvas_sync_spec.rb