canvas_sync 0.12.0 → 0.16.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/canvas_sync.rb +85 -30
  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/migrations/create_group_memberships.rb +18 -0
  10. data/lib/canvas_sync/generators/templates/migrations/create_groups.rb +23 -0
  11. data/lib/canvas_sync/generators/templates/migrations/create_pseudonyms.rb +18 -0
  12. data/lib/canvas_sync/generators/templates/migrations/create_submissions.rb +1 -0
  13. data/lib/canvas_sync/generators/templates/models/account.rb +11 -1
  14. data/lib/canvas_sync/generators/templates/models/admin.rb +2 -1
  15. data/lib/canvas_sync/generators/templates/models/assignment.rb +2 -1
  16. data/lib/canvas_sync/generators/templates/models/assignment_group.rb +2 -1
  17. data/lib/canvas_sync/generators/templates/models/context_module.rb +2 -1
  18. data/lib/canvas_sync/generators/templates/models/context_module_item.rb +2 -1
  19. data/lib/canvas_sync/generators/templates/models/course.rb +4 -2
  20. data/lib/canvas_sync/generators/templates/models/enrollment.rb +2 -1
  21. data/lib/canvas_sync/generators/templates/models/group.rb +19 -0
  22. data/lib/canvas_sync/generators/templates/models/group_membership.rb +17 -0
  23. data/lib/canvas_sync/generators/templates/models/pseudonym.rb +8 -0
  24. data/lib/canvas_sync/generators/templates/models/role.rb +2 -1
  25. data/lib/canvas_sync/generators/templates/models/section.rb +2 -1
  26. data/lib/canvas_sync/generators/templates/models/submission.rb +3 -1
  27. data/lib/canvas_sync/generators/templates/models/term.rb +2 -1
  28. data/lib/canvas_sync/generators/templates/models/user.rb +4 -1
  29. data/lib/canvas_sync/importers/bulk_importer.rb +7 -1
  30. data/lib/canvas_sync/importers/legacy_importer.rb +4 -2
  31. data/lib/canvas_sync/job.rb +3 -1
  32. data/lib/canvas_sync/job_chain.rb +57 -0
  33. data/lib/canvas_sync/jobs/{sync_users_job.rb → sync_accounts_job.rb} +11 -6
  34. data/lib/canvas_sync/jobs/sync_provisioning_report_job.rb +2 -0
  35. data/lib/canvas_sync/processors/model_mappings.yml +81 -0
  36. data/lib/canvas_sync/processors/provisioning_report_processor.rb +28 -0
  37. data/lib/canvas_sync/record.rb +9 -0
  38. data/lib/canvas_sync/version.rb +1 -1
  39. data/spec/canvas_sync/canvas_sync_spec.rb +19 -16
  40. data/spec/canvas_sync/models/accounts_spec.rb +3 -0
  41. data/spec/canvas_sync/models/course_spec.rb +4 -0
  42. data/spec/canvas_sync/models/group_membership_spec.rb +26 -0
  43. data/spec/canvas_sync/models/group_spec.rb +26 -0
  44. data/spec/canvas_sync/models/user_spec.rb +2 -0
  45. data/spec/canvas_sync/processors/provisioning_report_processor_spec.rb +20 -0
  46. data/spec/dummy/app/models/account.rb +8 -1
  47. data/spec/dummy/app/models/admin.rb +2 -1
  48. data/spec/dummy/app/models/assignment.rb +2 -1
  49. data/spec/dummy/app/models/assignment_group.rb +2 -1
  50. data/spec/dummy/app/models/context_module.rb +2 -1
  51. data/spec/dummy/app/models/context_module_item.rb +2 -1
  52. data/spec/dummy/app/models/course.rb +4 -2
  53. data/spec/dummy/app/models/enrollment.rb +2 -1
  54. data/spec/dummy/app/models/group.rb +25 -0
  55. data/spec/dummy/app/models/group_membership.rb +23 -0
  56. data/spec/dummy/app/models/role.rb +2 -1
  57. data/spec/dummy/app/models/section.rb +2 -1
  58. data/spec/dummy/app/models/submission.rb +2 -1
  59. data/spec/dummy/app/models/term.rb +2 -1
  60. data/spec/dummy/app/models/user.rb +3 -1
  61. data/spec/dummy/config/application.rb +12 -1
  62. data/spec/dummy/config/database.yml +11 -11
  63. data/spec/dummy/config/environments/development.rb +3 -3
  64. data/spec/dummy/config/initializers/assets.rb +1 -1
  65. data/spec/dummy/db/migrate/20190702203627_create_submissions.rb +1 -0
  66. data/spec/dummy/db/migrate/20200415171620_create_groups.rb +29 -0
  67. data/spec/dummy/db/migrate/20200416214248_create_group_memberships.rb +24 -0
  68. data/spec/dummy/db/schema.rb +31 -1
  69. data/spec/factories/group_factory.rb +8 -0
  70. data/spec/factories/group_membership_factory.rb +6 -0
  71. data/spec/support/fixtures/reports/group_memberships.csv +3 -0
  72. data/spec/support/fixtures/reports/groups.csv +3 -0
  73. data/spec/support/fixtures/reports/submissions.csv +3 -3
  74. metadata +36 -6
  75. data/spec/canvas_sync/jobs/sync_users_job_spec.rb +0 -15
@@ -0,0 +1,24 @@
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 CreateGroupMemberships < ActiveRecord::Migration[5.1]
10
+ def change
11
+ create_table :group_memberships do |t|
12
+ t.bigint :canvas_id, null: false
13
+ t.bigint :canvas_user_id, null: false
14
+ t.bigint :canvas_group_id, null: false
15
+ t.string :group_sis_id
16
+ t.string :user_sis_id
17
+ t.string :workflow_state
18
+
19
+ t.timestamps
20
+ end
21
+
22
+ add_index :group_memberships, :canvas_id, unique: true
23
+ end
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: 20190927204546) do
13
+ ActiveRecord::Schema.define(version: 2020_04_16_214248) do
14
14
 
15
15
  # These are extensions that must be enabled in order to support this database
16
16
  enable_extension "plpgsql"
@@ -162,6 +162,35 @@ ActiveRecord::Schema.define(version: 20190927204546) do
162
162
  t.index ["canvas_user_id"], name: "index_enrollments_on_canvas_user_id"
163
163
  end
164
164
 
165
+ create_table "group_memberships", force: :cascade do |t|
166
+ t.bigint "canvas_id", null: false
167
+ t.bigint "canvas_user_id", null: false
168
+ t.bigint "canvas_group_id", null: false
169
+ t.string "group_sis_id"
170
+ t.string "user_sis_id"
171
+ t.string "workflow_state"
172
+ t.datetime "created_at", null: false
173
+ t.datetime "updated_at", null: false
174
+ t.index ["canvas_id"], name: "index_group_memberships_on_canvas_id", unique: true
175
+ end
176
+
177
+ create_table "groups", force: :cascade do |t|
178
+ t.bigint "canvas_id", null: false
179
+ t.string "sis_id"
180
+ t.bigint "canvas_group_category_id"
181
+ t.string "group_category_sis_id"
182
+ t.bigint "canvas_account_id"
183
+ t.bigint "canvas_course_id"
184
+ t.string "name"
185
+ t.string "workflow_state"
186
+ t.bigint "context_id"
187
+ t.string "context_type"
188
+ t.integer "max_membership"
189
+ t.datetime "created_at", null: false
190
+ t.datetime "updated_at", null: false
191
+ t.index ["canvas_id"], name: "index_groups_on_canvas_id", unique: true
192
+ end
193
+
165
194
  create_table "roles", force: :cascade do |t|
166
195
  t.integer "canvas_id", null: false
167
196
  t.string "label"
@@ -196,6 +225,7 @@ ActiveRecord::Schema.define(version: 20190927204546) do
196
225
  t.bigint "canvas_assignment_id"
197
226
  t.bigint "canvas_user_id"
198
227
  t.datetime "submitted_at"
228
+ t.datetime "due_at"
199
229
  t.datetime "graded_at"
200
230
  t.float "score"
201
231
  t.float "points_possible"
@@ -0,0 +1,8 @@
1
+ FactoryGirl.define do
2
+ factory :group do
3
+ canvas_id { SecureRandom.random_number(100_000_000) }
4
+ sis_id { SecureRandom.hex }
5
+ name 'Some User Group'
6
+ workflow_state 'available'
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ factory :group_membership do
3
+ canvas_id { SecureRandom.random_number(100_000_000) }
4
+ workflow_state 'accepted'
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ canvas_group_id,group_id,canvas_user_id,user_id,status,created_by_sis,canvas_group_membership_id
2
+ 1,,10,,accepted,false,50
3
+ 2,,11,,accepted,false,51
@@ -0,0 +1,3 @@
1
+ canvas_group_id,group_id,canvas_group_category_id,group_category_id,canvas_account_id,account_id,canvas_course_id,course_id,name,status,created_by_sis,context_id,context_type,max_membership
2
+ 50,sis1,10,,1,,,,Group1,available,false,1,Account,
3
+ 51,sis2,2,,,,1,coursesis,Group2,available,false,1,Course,1
@@ -1,3 +1,3 @@
1
- "canvas user id","sis user id","user name","canvas course id","sis course id","course name","assignment id","assignment name","submission date","graded date","score","points possible","submission id","workflow state","excused"
2
- 1,1,userName,1,1,courseName,1,assignmentName,2017-09-21 18:28:15 UTC,2017-09-21 19:36:23 UTC,5,10,1,graded,true
3
- 1,1,userName,1,1,courseName,2,assignment2Name,2017-09-21 18:28:15 UTC,2017-09-21 19:36:23 UTC,5,10,2,submitted,false
1
+ "canvas user id","sis user id","user name","canvas course id","sis course id","course name","assignment id","assignment name","submission date","graded date","score","points possible","submission id","workflow state","excused","due at"
2
+ 1,1,userName,1,1,courseName,1,assignmentName,2017-09-21 18:28:15 UTC,2017-09-21 19:36:23 UTC,5,10,1,graded,true,2017-09-27 18:28:15 UTC
3
+ 1,1,userName,1,1,courseName,2,assignment2Name,2017-09-21 18:28:15 UTC,2017-09-21 19:36:23 UTC,5,10,2,submitted,false,2017-09-28 18:28:15 UTC
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.16.1
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-08-28 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
@@ -334,6 +338,9 @@ files:
334
338
  - lib/canvas_sync/generators/templates/migrations/create_context_modules.rb
335
339
  - lib/canvas_sync/generators/templates/migrations/create_courses.rb
336
340
  - lib/canvas_sync/generators/templates/migrations/create_enrollments.rb
341
+ - lib/canvas_sync/generators/templates/migrations/create_group_memberships.rb
342
+ - lib/canvas_sync/generators/templates/migrations/create_groups.rb
343
+ - lib/canvas_sync/generators/templates/migrations/create_pseudonyms.rb
337
344
  - lib/canvas_sync/generators/templates/migrations/create_roles.rb
338
345
  - lib/canvas_sync/generators/templates/migrations/create_sections.rb
339
346
  - lib/canvas_sync/generators/templates/migrations/create_submissions.rb
@@ -347,6 +354,9 @@ files:
347
354
  - lib/canvas_sync/generators/templates/models/context_module_item.rb
348
355
  - lib/canvas_sync/generators/templates/models/course.rb
349
356
  - lib/canvas_sync/generators/templates/models/enrollment.rb
357
+ - lib/canvas_sync/generators/templates/models/group.rb
358
+ - lib/canvas_sync/generators/templates/models/group_membership.rb
359
+ - lib/canvas_sync/generators/templates/models/pseudonym.rb
350
360
  - lib/canvas_sync/generators/templates/models/role.rb
351
361
  - lib/canvas_sync/generators/templates/models/section.rb
352
362
  - lib/canvas_sync/generators/templates/models/submission.rb
@@ -367,10 +377,12 @@ files:
367
377
  - lib/canvas_sync/importers/bulk_importer.rb
368
378
  - lib/canvas_sync/importers/legacy_importer.rb
369
379
  - lib/canvas_sync/job.rb
380
+ - lib/canvas_sync/job_chain.rb
370
381
  - lib/canvas_sync/jobs/fork_gather.rb
371
382
  - lib/canvas_sync/jobs/report_checker.rb
372
383
  - lib/canvas_sync/jobs/report_processor_job.rb
373
384
  - lib/canvas_sync/jobs/report_starter.rb
385
+ - lib/canvas_sync/jobs/sync_accounts_job.rb
374
386
  - lib/canvas_sync/jobs/sync_admins_job.rb
375
387
  - lib/canvas_sync/jobs/sync_assignment_groups_job.rb
376
388
  - lib/canvas_sync/jobs/sync_assignments_job.rb
@@ -381,7 +393,6 @@ files:
381
393
  - lib/canvas_sync/jobs/sync_simple_table_job.rb
382
394
  - lib/canvas_sync/jobs/sync_submissions_job.rb
383
395
  - lib/canvas_sync/jobs/sync_terms_job.rb
384
- - lib/canvas_sync/jobs/sync_users_job.rb
385
396
  - lib/canvas_sync/processors/assignment_groups_processor.rb
386
397
  - lib/canvas_sync/processors/assignments_processor.rb
387
398
  - lib/canvas_sync/processors/context_module_items_processor.rb
@@ -391,6 +402,7 @@ files:
391
402
  - lib/canvas_sync/processors/provisioning_report_processor.rb
392
403
  - lib/canvas_sync/processors/report_processor.rb
393
404
  - lib/canvas_sync/processors/submissions_processor.rb
405
+ - lib/canvas_sync/record.rb
394
406
  - lib/canvas_sync/sidekiq_job.rb
395
407
  - lib/canvas_sync/version.rb
396
408
  - spec/canvas_sync/canvas_sync_spec.rb
@@ -409,7 +421,6 @@ files:
409
421
  - spec/canvas_sync/jobs/sync_simple_table_job_spec.rb
410
422
  - spec/canvas_sync/jobs/sync_submissions_job_spec.rb
411
423
  - spec/canvas_sync/jobs/sync_terms_job_spec.rb
412
- - spec/canvas_sync/jobs/sync_users_job_spec.rb
413
424
  - spec/canvas_sync/models/accounts_spec.rb
414
425
  - spec/canvas_sync/models/admins_spec.rb
415
426
  - spec/canvas_sync/models/assignment_group_spec.rb
@@ -418,6 +429,8 @@ files:
418
429
  - spec/canvas_sync/models/context_module_spec.rb
419
430
  - spec/canvas_sync/models/course_spec.rb
420
431
  - spec/canvas_sync/models/enrollment_spec.rb
432
+ - spec/canvas_sync/models/group_membership_spec.rb
433
+ - spec/canvas_sync/models/group_spec.rb
421
434
  - spec/canvas_sync/models/roles_spec.rb
422
435
  - spec/canvas_sync/models/section_spec.rb
423
436
  - spec/canvas_sync/models/submission_spec.rb
@@ -443,6 +456,8 @@ files:
443
456
  - spec/dummy/app/models/context_module_item.rb
444
457
  - spec/dummy/app/models/course.rb
445
458
  - spec/dummy/app/models/enrollment.rb
459
+ - spec/dummy/app/models/group.rb
460
+ - spec/dummy/app/models/group_membership.rb
446
461
  - spec/dummy/app/models/role.rb
447
462
  - spec/dummy/app/models/section.rb
448
463
  - spec/dummy/app/models/submission.rb
@@ -503,6 +518,8 @@ files:
503
518
  - spec/dummy/db/migrate/20190702203632_create_context_module_items.rb
504
519
  - spec/dummy/db/migrate/20190927204545_create_roles.rb
505
520
  - spec/dummy/db/migrate/20190927204546_create_admins.rb
521
+ - spec/dummy/db/migrate/20200415171620_create_groups.rb
522
+ - spec/dummy/db/migrate/20200416214248_create_group_memberships.rb
506
523
  - spec/dummy/db/schema.rb
507
524
  - spec/dummy/db/test.sqlite3
508
525
  - spec/dummy/log/development.log
@@ -515,6 +532,8 @@ files:
515
532
  - spec/factories/context_module_item_factory.rb
516
533
  - spec/factories/course_factory.rb
517
534
  - spec/factories/enrollment_factory.rb
535
+ - spec/factories/group_factory.rb
536
+ - spec/factories/group_membership_factory.rb
518
537
  - spec/factories/role_factory.rb
519
538
  - spec/factories/section_factory.rb
520
539
  - spec/factories/submission_factory.rb
@@ -533,6 +552,8 @@ files:
533
552
  - spec/support/fixtures/reports/context_modules.csv
534
553
  - spec/support/fixtures/reports/courses.csv
535
554
  - spec/support/fixtures/reports/enrollments.csv
555
+ - spec/support/fixtures/reports/group_memberships.csv
556
+ - spec/support/fixtures/reports/groups.csv
536
557
  - spec/support/fixtures/reports/provisioning_csv
537
558
  - spec/support/fixtures/reports/provisioning_csv_unzipped/courses.csv
538
559
  - spec/support/fixtures/reports/provisioning_csv_unzipped/users.csv
@@ -558,7 +579,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
558
579
  - !ruby/object:Gem::Version
559
580
  version: '0'
560
581
  requirements: []
561
- rubygems_version: 3.0.3
582
+ rubygems_version: 3.1.2
562
583
  signing_key:
563
584
  specification_version: 4
564
585
  summary: Gem for generating Canvas models and migrations and syncing data from Canvas
@@ -579,7 +600,6 @@ test_files:
579
600
  - spec/canvas_sync/jobs/sync_simple_table_job_spec.rb
580
601
  - spec/canvas_sync/jobs/sync_submissions_job_spec.rb
581
602
  - spec/canvas_sync/jobs/sync_terms_job_spec.rb
582
- - spec/canvas_sync/jobs/sync_users_job_spec.rb
583
603
  - spec/canvas_sync/models/accounts_spec.rb
584
604
  - spec/canvas_sync/models/admins_spec.rb
585
605
  - spec/canvas_sync/models/assignment_group_spec.rb
@@ -588,6 +608,8 @@ test_files:
588
608
  - spec/canvas_sync/models/context_module_spec.rb
589
609
  - spec/canvas_sync/models/course_spec.rb
590
610
  - spec/canvas_sync/models/enrollment_spec.rb
611
+ - spec/canvas_sync/models/group_membership_spec.rb
612
+ - spec/canvas_sync/models/group_spec.rb
591
613
  - spec/canvas_sync/models/roles_spec.rb
592
614
  - spec/canvas_sync/models/section_spec.rb
593
615
  - spec/canvas_sync/models/submission_spec.rb
@@ -613,6 +635,8 @@ test_files:
613
635
  - spec/dummy/app/models/context_module_item.rb
614
636
  - spec/dummy/app/models/course.rb
615
637
  - spec/dummy/app/models/enrollment.rb
638
+ - spec/dummy/app/models/group.rb
639
+ - spec/dummy/app/models/group_membership.rb
616
640
  - spec/dummy/app/models/role.rb
617
641
  - spec/dummy/app/models/section.rb
618
642
  - spec/dummy/app/models/submission.rb
@@ -673,6 +697,8 @@ test_files:
673
697
  - spec/dummy/db/migrate/20190702203632_create_context_module_items.rb
674
698
  - spec/dummy/db/migrate/20190927204545_create_roles.rb
675
699
  - spec/dummy/db/migrate/20190927204546_create_admins.rb
700
+ - spec/dummy/db/migrate/20200415171620_create_groups.rb
701
+ - spec/dummy/db/migrate/20200416214248_create_group_memberships.rb
676
702
  - spec/dummy/db/schema.rb
677
703
  - spec/dummy/db/test.sqlite3
678
704
  - spec/dummy/log/development.log
@@ -685,6 +711,8 @@ test_files:
685
711
  - spec/factories/context_module_item_factory.rb
686
712
  - spec/factories/course_factory.rb
687
713
  - spec/factories/enrollment_factory.rb
714
+ - spec/factories/group_factory.rb
715
+ - spec/factories/group_membership_factory.rb
688
716
  - spec/factories/role_factory.rb
689
717
  - spec/factories/section_factory.rb
690
718
  - spec/factories/submission_factory.rb
@@ -703,6 +731,8 @@ test_files:
703
731
  - spec/support/fixtures/reports/context_modules.csv
704
732
  - spec/support/fixtures/reports/courses.csv
705
733
  - spec/support/fixtures/reports/enrollments.csv
734
+ - spec/support/fixtures/reports/group_memberships.csv
735
+ - spec/support/fixtures/reports/groups.csv
706
736
  - spec/support/fixtures/reports/provisioning_csv
707
737
  - spec/support/fixtures/reports/provisioning_csv_unzipped/courses.csv
708
738
  - spec/support/fixtures/reports/provisioning_csv_unzipped/users.csv
@@ -1,15 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe CanvasSync::Jobs::SyncUsersJob do
4
- describe '#perform' do
5
- it 'enqueues a ReportStarter for a provisioning report across all terms with just users' do
6
- expect_any_instance_of(Bearcat::Client).to receive(:start_report)
7
- .with('self', 'proservices_provisioning_csv', { parameters: { users: true, include_deleted: true } })
8
- .and_return({ 'id' => 1 })
9
-
10
- expect(CanvasSync::Jobs::ReportChecker).to receive(:set).and_call_original
11
-
12
- CanvasSync::Jobs::SyncUsersJob.perform_now({ jobs: [], global_options: {}}, {})
13
- end
14
- end
15
- end