canvas_sync 0.17.27.beta1 → 0.17.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 413b8669b85123f239a5917982347c9cb90bd56229c42e11a92ce8bc619171f5
4
- data.tar.gz: b99de51cad35d7c894ed54ab8910cbe6d0b594cadab814683396350dbbc4b95a
3
+ metadata.gz: 32eaa6fa25c776f85402a9b3fb36e20f69d8954106cca5759db80ee01298b5a5
4
+ data.tar.gz: 9d2b05d16d6770cbe3b0e4053e5c22c01f416bc61350a14131c509978d9305d5
5
5
  SHA512:
6
- metadata.gz: e78f116e14b49c88fb04d95b33623c99a31c6a09735491361b0c287a2d48fff2bf061710f5715854b8601b7eb0c1aa3de9bfd93d87d08f71c260eac830a08fce
7
- data.tar.gz: 361de97175217d570b0e60f4b3737a38d685ea4404d568ad35df281f495f08288284d734a02e2f8c5809c2a81e3863bb3030a217ce5d5bab71ca60d889eff31c
6
+ metadata.gz: 1abd4a0de86b2f22b8f131750533c23507b3b0d354d24a4cd645e5bf368863561e386a2165ac046444fb2b86ca5114ef0de7c7fb45979eb780ea5d01640d9ab9
7
+ data.tar.gz: a6f794c96ec97e3e39090421d4c339b3afb8d47024332a87b90324b17e2e13c3bc56455c781d0a95c1d391d3b84a08059d534792344b357bee14adccff0109d2
data/README.md CHANGED
@@ -34,6 +34,7 @@ The following custom reports are required for the specified models:
34
34
  - assignment_groups = "Assignment Group Export" (proserv_assignment_group_export_csv)
35
35
  - context_modules = "Professional Services Context Modules Report" (proserv_context_modules_csv)
36
36
  - context_module_items = "Professional Services Context Module Items Report" (proserv_context_module_items_csv)
37
+ - content_migrations = "Professional Services Content Migrations Report" (proserv_content_migrations_csv)
37
38
 
38
39
  ## Prerequisites
39
40
 
@@ -0,0 +1,24 @@
1
+ # <%= autogenerated_migration_warning %>
2
+
3
+ class CreateContentMigrations < ActiveRecord::Migration[5.1]
4
+ def change
5
+ create_table :content_migrations do |t|
6
+ t.bigint :canvas_id
7
+ t.bigint :canvas_context_id
8
+ t.string :canvas_context_type
9
+ t.string :workflow_state
10
+ t.text :migration_settings
11
+ t.datetime :started_at
12
+ t.datetime :finished_at
13
+ t.float :progress
14
+ t.bigint :canvas_source_course_id
15
+ t.string :migration_type
16
+ t.bigint :canvas_child_subscription_id
17
+ t.bigint :canvas_root_account_id
18
+
19
+ t.timestamps
20
+ end
21
+
22
+ add_index :content_migrations, :canvas_id, unique: true
23
+ end
24
+ end
@@ -0,0 +1,10 @@
1
+ # <%= autogenerated_model_warning %>
2
+
3
+ class ContentMigration < ApplicationRecord
4
+ include CanvasSync::Record
5
+ include CanvasSync::Concerns::ApiSyncable
6
+
7
+ validates :canvas_id, uniqueness: true, presence: true
8
+ belongs_to :context, polymorphic: true, optional: true, primary_key: :canvas_id, foreign_key: :canvas_context_id, foreign_type: :canvas_context_type
9
+
10
+ end
@@ -0,0 +1,20 @@
1
+ module CanvasSync
2
+ module Jobs
3
+ class SyncContentMigrationsJob < ReportStarter
4
+ # Syncs ContentMigrations
5
+ #
6
+ # Starts a report processor for the content migrations report
7
+ # (the proserv_content_migrations_csv report must be enabled)
8
+ #
9
+ # @param options [Hash]
10
+ def perform(options)
11
+ super(
12
+ "proserv_content_migrations_csv",
13
+ merge_report_params(options),
14
+ CanvasSync::Processors::ContentMigrationsProcessor.to_s,
15
+ {},
16
+ )
17
+ end
18
+ end
19
+ end
20
+ end
@@ -20,9 +20,9 @@ module CanvasSync
20
20
  end
21
21
 
22
22
  JobBatches::ManagedBatchJob.make_batch(jobs, ordered: false, concurrency: true) do |b|
23
- b.description = "TermBatchJob(#{term.canvas_id}) Root"
23
+ b.description = "TermBatchJob(#{term_id}) Root"
24
24
  b.context = local_context
25
- b.on(:success, "#{self.class.to_s}.batch_finished") unless options[:mark_synced] == false
25
+ b.on(:success, "#{self.class.to_s}.batch_finished")
26
26
  end
27
27
  end
28
28
  else
@@ -0,0 +1,19 @@
1
+ require_relative "./report_processor"
2
+
3
+ module CanvasSync
4
+ module Processors
5
+ # Processes a content migrations report using the bulk importer.
6
+ #
7
+ # @param report_file_path [String]
8
+ # @param options [Hash]
9
+ class ContentMigrationsProcessor < ReportProcessor
10
+ def self.process(report_file_path, _options, report_id)
11
+ new(report_file_path, _options)
12
+ end
13
+
14
+ def initialize(report_file_path, options)
15
+ do_bulk_import(report_file_path, ContentMigration, options: options)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -469,3 +469,43 @@ grading_period_groups:
469
469
  status:
470
470
  database_column_name: workflow_state
471
471
  type: string
472
+
473
+ content_migrations:
474
+ conflict_target: canvas_migration_id
475
+ report_columns:
476
+ canvas_migration_id:
477
+ database_column_name: canvas_id
478
+ type: integer
479
+ canvas_context_id:
480
+ database_column_name: canvas_context_id
481
+ type: integer
482
+ canvas_context_type:
483
+ database_column_name: canvas_context_type
484
+ type: string
485
+ workflow_state:
486
+ database_column_name: workflow_state
487
+ type: string
488
+ migration_settings:
489
+ database_column_name: migration_settings
490
+ type: text
491
+ started_at:
492
+ database_column_name: started_at
493
+ type: datetime
494
+ finished_at:
495
+ database_column_name: finished_at
496
+ type: datetime
497
+ progress:
498
+ database_column_name: progress
499
+ type: float
500
+ canvas_source_course_id:
501
+ database_column_name: canvas_source_course_id
502
+ type: integer
503
+ migration_type:
504
+ database_column_name: migration_type
505
+ type: string
506
+ canvas_child_subscription_id:
507
+ database_column_name: canvas_child_subscription_id
508
+ type: integer
509
+ canvas_root_account_id:
510
+ database_column_name: canvas_root_account_id
511
+ type: integer
@@ -1,3 +1,3 @@
1
1
  module CanvasSync
2
- VERSION = "0.17.27.beta1".freeze
2
+ VERSION = "0.17.29".freeze
3
3
  end
data/lib/canvas_sync.rb CHANGED
@@ -44,6 +44,7 @@ module CanvasSync
44
44
  user_observers
45
45
  grading_periods
46
46
  grading_period_groups
47
+ content_migrations
47
48
  ].freeze
48
49
 
49
50
  SUPPORTED_TERM_SCOPE_MODELS = %w[
@@ -150,6 +151,7 @@ module CanvasSync
150
151
  assignment_groups: CanvasSync::Jobs::SyncAssignmentGroupsJob,
151
152
  context_modules: CanvasSync::Jobs::SyncContextModulesJob,
152
153
  context_module_items: CanvasSync::Jobs::SyncContextModuleItemsJob,
154
+ content_migrations: CanvasSync::Jobs::SyncContentMigrationsJob,
153
155
  }.with_indifferent_access
154
156
 
155
157
  root_chain = base_canvas_sync_chain(**kwargs, globals: options[:global] || kwargs[:globals])
@@ -0,0 +1,30 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe CanvasSync::Jobs::SyncContentMigrationsJob do
4
+ describe "#perform" do
5
+ context "no parameters is specified" do
6
+ it "enqueues a ReportStarter for the proserv_content_migrations_csv" do
7
+ expect_any_instance_of(Bearcat::Client).to receive(:start_report)
8
+ .with("self", "proserv_content_migrations_csv", { parameters: { } })
9
+ .and_return("id" => 1)
10
+
11
+ expect(CanvasSync::Jobs::ReportChecker).to receive(:set).and_call_original
12
+
13
+ CanvasSync::Jobs::SyncContentMigrationsJob.perform_now({})
14
+ end
15
+ end
16
+
17
+ context "updated_after parameters is specified" do
18
+ it "enqueues a ReportStarter for the proserv_content_migrations_csv and get data from given date" do
19
+ expect_any_instance_of(Bearcat::Client).to receive(:start_report)
20
+ .with("self", "proserv_content_migrations_csv", { parameters: { updated_after: 6.hours.ago.to_s } })
21
+ .and_return("id" => 1)
22
+
23
+ expect(CanvasSync::Jobs::ReportChecker).to receive(:set).and_call_original
24
+
25
+ set_batch_context(updated_after: 6.hours.ago.to_s)
26
+ CanvasSync::Jobs::SyncContentMigrationsJob.perform_now({})
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,13 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe CanvasSync::Processors::ContentMigrationsProcessor do
4
+ let(:subject) { CanvasSync::Processors::ContentMigrationsProcessor }
5
+
6
+ describe "#process" do
7
+ it "inserts content migrations" do
8
+ expect {
9
+ subject.process("spec/support/fixtures/reports/content_migrations.csv", {}, 1)
10
+ }.to change { ContentMigration.count }.by(2)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ # #
2
+ # AUTO GENERATED MODEL
3
+ # This model was auto generated by the CanvasSync Gem.
4
+ # You can customize it as needed, but make sure you test
5
+ # any changes you make to the auto generated methods.
6
+ #
7
+
8
+
9
+ class ContentMigration < ApplicationRecord
10
+ include CanvasSync::Record
11
+ include CanvasSync::Concerns::ApiSyncable
12
+
13
+ validates :canvas_id, uniqueness: true, presence: true
14
+ belongs_to :context, polymorphic: true, optional: true, primary_key: :canvas_id, foreign_key: :canvas_context_id, foreign_type: :canvas_context_type
15
+
16
+ end
@@ -0,0 +1,30 @@
1
+ # #
2
+ # AUTO GENERATED MIGRATION
3
+ # This migration was auto generated by the CanvasSync Gem.
4
+ # You can add new columns to this table, but removing or
5
+ # re-naming ones created here may break Canvas Syncing.
6
+ #
7
+
8
+
9
+ class CreateContentMigrations < ActiveRecord::Migration[5.1]
10
+ def change
11
+ create_table :content_migrations do |t|
12
+ t.bigint :canvas_id
13
+ t.bigint :canvas_context_id
14
+ t.string :canvas_context_type
15
+ t.string :workflow_state
16
+ t.text :migration_settings
17
+ t.datetime :started_at
18
+ t.datetime :finished_at
19
+ t.float :progress
20
+ t.bigint :canvas_source_course_id
21
+ t.string :migration_type
22
+ t.bigint :canvas_child_subscription_id
23
+ t.bigint :canvas_root_account_id
24
+
25
+ t.timestamps
26
+ end
27
+
28
+ add_index :content_migrations, :canvas_id, unique: true
29
+ end
30
+ 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_10_01_184920) do
13
+ ActiveRecord::Schema.define(version: 2022_03_08_072643) do
14
14
 
15
15
  # These are extensions that must be enabled in order to support this database
16
16
  enable_extension "plpgsql"
@@ -110,6 +110,24 @@ ActiveRecord::Schema.define(version: 2021_10_01_184920) do
110
110
  t.string "batch_bid"
111
111
  end
112
112
 
113
+ create_table "content_migrations", force: :cascade do |t|
114
+ t.bigint "canvas_id"
115
+ t.bigint "canvas_context_id"
116
+ t.string "canvas_context_type"
117
+ t.string "workflow_state"
118
+ t.text "migration_settings"
119
+ t.datetime "started_at"
120
+ t.datetime "finished_at"
121
+ t.float "progress"
122
+ t.bigint "canvas_source_course_id"
123
+ t.string "migration_type"
124
+ t.bigint "canvas_child_subscription_id"
125
+ t.bigint "canvas_root_account_id"
126
+ t.datetime "created_at", null: false
127
+ t.datetime "updated_at", null: false
128
+ t.index ["canvas_id"], name: "index_content_migrations_on_canvas_id", unique: true
129
+ end
130
+
113
131
  create_table "context_module_items", force: :cascade do |t|
114
132
  t.bigint "canvas_id"
115
133
  t.bigint "canvas_context_module_id"
@@ -0,0 +1,3 @@
1
+ canvas_migration_id,canvas_context_id,canvas_context_type,workflow_state,migration_settings,started_at,finished_at,progress,canvas_source_course_id,migration_type,canvas_child_subscription_id,canvas_root_account_id
2
+ 101,1250,Course,imported,,2022-02-18 10:10:40,2022-02-18 10:11:40,100,1200,course_copy_importer,,1
3
+ 102,1251,Course,imported,,2022-02-18 10:10:40,2022-02-18 10:11:40,100,1120,master_course_import,3,1
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.17.27.beta1
4
+ version: 0.17.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Collings
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-07 00:00:00.000000000 Z
11
+ date: 2022-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -381,6 +381,7 @@ files:
381
381
  - lib/canvas_sync/generators/templates/migrations/create_admins.rb
382
382
  - lib/canvas_sync/generators/templates/migrations/create_assignment_groups.rb
383
383
  - lib/canvas_sync/generators/templates/migrations/create_assignments.rb
384
+ - lib/canvas_sync/generators/templates/migrations/create_content_migrations.rb
384
385
  - lib/canvas_sync/generators/templates/migrations/create_context_module_items.rb
385
386
  - lib/canvas_sync/generators/templates/migrations/create_context_modules.rb
386
387
  - lib/canvas_sync/generators/templates/migrations/create_courses.rb
@@ -400,6 +401,7 @@ files:
400
401
  - lib/canvas_sync/generators/templates/models/admin.rb
401
402
  - lib/canvas_sync/generators/templates/models/assignment.rb
402
403
  - lib/canvas_sync/generators/templates/models/assignment_group.rb
404
+ - lib/canvas_sync/generators/templates/models/content_migration.rb
403
405
  - lib/canvas_sync/generators/templates/models/context_module.rb
404
406
  - lib/canvas_sync/generators/templates/models/context_module_item.rb
405
407
  - lib/canvas_sync/generators/templates/models/course.rb
@@ -469,6 +471,7 @@ files:
469
471
  - lib/canvas_sync/jobs/sync_admins_job.rb
470
472
  - lib/canvas_sync/jobs/sync_assignment_groups_job.rb
471
473
  - lib/canvas_sync/jobs/sync_assignments_job.rb
474
+ - lib/canvas_sync/jobs/sync_content_migrations_job.rb
472
475
  - lib/canvas_sync/jobs/sync_context_module_items_job.rb
473
476
  - lib/canvas_sync/jobs/sync_context_modules_job.rb
474
477
  - lib/canvas_sync/jobs/sync_provisioning_report_job.rb
@@ -480,6 +483,7 @@ files:
480
483
  - lib/canvas_sync/misc_helper.rb
481
484
  - lib/canvas_sync/processors/assignment_groups_processor.rb
482
485
  - lib/canvas_sync/processors/assignments_processor.rb
486
+ - lib/canvas_sync/processors/content_migrations_processor.rb
483
487
  - lib/canvas_sync/processors/context_module_items_processor.rb
484
488
  - lib/canvas_sync/processors/context_modules_processor.rb
485
489
  - lib/canvas_sync/processors/model_mappings.yml
@@ -498,6 +502,7 @@ files:
498
502
  - spec/canvas_sync/jobs/sync_admins_job_spec.rb
499
503
  - spec/canvas_sync/jobs/sync_assignment_groups_job_spec.rb
500
504
  - spec/canvas_sync/jobs/sync_assignments_job_spec.rb
505
+ - spec/canvas_sync/jobs/sync_content_migrations_job_spec.rb
501
506
  - spec/canvas_sync/jobs/sync_context_module_items_job_spec.rb
502
507
  - spec/canvas_sync/jobs/sync_context_modules_job_spec.rb
503
508
  - spec/canvas_sync/jobs/sync_provisioning_report_job_spec.rb
@@ -522,6 +527,7 @@ files:
522
527
  - spec/canvas_sync/models/user_spec.rb
523
528
  - spec/canvas_sync/processors/assignment_groups_processor_spec.rb
524
529
  - spec/canvas_sync/processors/assignments_processor_spec.rb
530
+ - spec/canvas_sync/processors/content_migrations_processor_spec.rb
525
531
  - spec/canvas_sync/processors/context_module_items_processor_spec.rb
526
532
  - spec/canvas_sync/processors/context_modules_processor_spec.rb
527
533
  - spec/canvas_sync/processors/normal_processor_spec.rb
@@ -536,6 +542,7 @@ files:
536
542
  - spec/dummy/app/models/application_record.rb
537
543
  - spec/dummy/app/models/assignment.rb
538
544
  - spec/dummy/app/models/assignment_group.rb
545
+ - spec/dummy/app/models/content_migration.rb
539
546
  - spec/dummy/app/models/context_module.rb
540
547
  - spec/dummy/app/models/context_module_item.rb
541
548
  - spec/dummy/app/models/course.rb
@@ -612,9 +619,8 @@ files:
612
619
  - spec/dummy/db/migrate/20210907233329_create_user_observers.rb
613
620
  - spec/dummy/db/migrate/20210907233330_create_grading_periods.rb
614
621
  - spec/dummy/db/migrate/20211001184920_create_grading_period_groups.rb
622
+ - spec/dummy/db/migrate/20220308072643_create_content_migrations.rb
615
623
  - spec/dummy/db/schema.rb
616
- - spec/dummy/log/development.log
617
- - spec/dummy/log/test.log
618
624
  - spec/factories/account_factory.rb
619
625
  - spec/factories/admin_factory.rb
620
626
  - spec/factories/assignment_factory.rb
@@ -654,6 +660,7 @@ files:
654
660
  - spec/support/fixtures/canvas_responses/terms.json
655
661
  - spec/support/fixtures/reports/assignment_groups.csv
656
662
  - spec/support/fixtures/reports/assignments.csv
663
+ - spec/support/fixtures/reports/content_migrations.csv
657
664
  - spec/support/fixtures/reports/context_module_items.csv
658
665
  - spec/support/fixtures/reports/context_modules.csv
659
666
  - spec/support/fixtures/reports/courses.csv
@@ -663,8 +670,6 @@ files:
663
670
  - spec/support/fixtures/reports/group_memberships.csv
664
671
  - spec/support/fixtures/reports/groups.csv
665
672
  - spec/support/fixtures/reports/provisioning_csv
666
- - spec/support/fixtures/reports/provisioning_csv_unzipped/courses.csv
667
- - spec/support/fixtures/reports/provisioning_csv_unzipped/users.csv
668
673
  - spec/support/fixtures/reports/sections.csv
669
674
  - spec/support/fixtures/reports/submissions.csv
670
675
  - spec/support/fixtures/reports/user_observers.csv
@@ -684,11 +689,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
684
689
  version: '0'
685
690
  required_rubygems_version: !ruby/object:Gem::Requirement
686
691
  requirements:
687
- - - ">"
692
+ - - ">="
688
693
  - !ruby/object:Gem::Version
689
- version: 1.3.1
694
+ version: '0'
690
695
  requirements: []
691
- rubygems_version: 3.0.3
696
+ rubygems_version: 3.0.3.1
692
697
  signing_key:
693
698
  specification_version: 4
694
699
  summary: Gem for generating Canvas models and migrations and syncing data from Canvas
@@ -701,6 +706,7 @@ test_files:
701
706
  - spec/canvas_sync/jobs/sync_admins_job_spec.rb
702
707
  - spec/canvas_sync/jobs/sync_assignment_groups_job_spec.rb
703
708
  - spec/canvas_sync/jobs/sync_assignments_job_spec.rb
709
+ - spec/canvas_sync/jobs/sync_content_migrations_job_spec.rb
704
710
  - spec/canvas_sync/jobs/sync_context_module_items_job_spec.rb
705
711
  - spec/canvas_sync/jobs/sync_context_modules_job_spec.rb
706
712
  - spec/canvas_sync/jobs/sync_provisioning_report_job_spec.rb
@@ -725,6 +731,7 @@ test_files:
725
731
  - spec/canvas_sync/models/user_spec.rb
726
732
  - spec/canvas_sync/processors/assignment_groups_processor_spec.rb
727
733
  - spec/canvas_sync/processors/assignments_processor_spec.rb
734
+ - spec/canvas_sync/processors/content_migrations_processor_spec.rb
728
735
  - spec/canvas_sync/processors/context_module_items_processor_spec.rb
729
736
  - spec/canvas_sync/processors/context_modules_processor_spec.rb
730
737
  - spec/canvas_sync/processors/normal_processor_spec.rb
@@ -739,6 +746,7 @@ test_files:
739
746
  - spec/dummy/app/models/application_record.rb
740
747
  - spec/dummy/app/models/assignment.rb
741
748
  - spec/dummy/app/models/assignment_group.rb
749
+ - spec/dummy/app/models/content_migration.rb
742
750
  - spec/dummy/app/models/context_module.rb
743
751
  - spec/dummy/app/models/context_module_item.rb
744
752
  - spec/dummy/app/models/course.rb
@@ -815,9 +823,8 @@ test_files:
815
823
  - spec/dummy/db/migrate/20210907233329_create_user_observers.rb
816
824
  - spec/dummy/db/migrate/20210907233330_create_grading_periods.rb
817
825
  - spec/dummy/db/migrate/20211001184920_create_grading_period_groups.rb
826
+ - spec/dummy/db/migrate/20220308072643_create_content_migrations.rb
818
827
  - spec/dummy/db/schema.rb
819
- - spec/dummy/log/development.log
820
- - spec/dummy/log/test.log
821
828
  - spec/factories/account_factory.rb
822
829
  - spec/factories/admin_factory.rb
823
830
  - spec/factories/assignment_factory.rb
@@ -857,6 +864,7 @@ test_files:
857
864
  - spec/support/fixtures/canvas_responses/terms.json
858
865
  - spec/support/fixtures/reports/assignment_groups.csv
859
866
  - spec/support/fixtures/reports/assignments.csv
867
+ - spec/support/fixtures/reports/content_migrations.csv
860
868
  - spec/support/fixtures/reports/context_module_items.csv
861
869
  - spec/support/fixtures/reports/context_modules.csv
862
870
  - spec/support/fixtures/reports/courses.csv
@@ -866,8 +874,6 @@ test_files:
866
874
  - spec/support/fixtures/reports/group_memberships.csv
867
875
  - spec/support/fixtures/reports/groups.csv
868
876
  - spec/support/fixtures/reports/provisioning_csv
869
- - spec/support/fixtures/reports/provisioning_csv_unzipped/courses.csv
870
- - spec/support/fixtures/reports/provisioning_csv_unzipped/users.csv
871
877
  - spec/support/fixtures/reports/sections.csv
872
878
  - spec/support/fixtures/reports/submissions.csv
873
879
  - spec/support/fixtures/reports/user_observers.csv