canvas_sync 0.1.5 → 0.1.7

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
  SHA1:
3
- metadata.gz: fbbd1539f4a800bb595198f919653e5b73454b7b
4
- data.tar.gz: 75508d1a64e10df9cd21b413ccfda805be8abdbd
3
+ metadata.gz: 68b09dd9ca869bb37f08c0691ce54f1efa4abb7e
4
+ data.tar.gz: 6615009014df4ddcd3b20e602549658fd659e0f9
5
5
  SHA512:
6
- metadata.gz: 0b346284748712d882fba0f6ce149d8750967c832b58bf3c9446b51e6f0b02ab2d3346d54d9e3c0fc653785517faa93d35a5123146797c35d6db0242a8db4d6a
7
- data.tar.gz: fa0fe09275931b1af5f08940515300543fcbbdf7557f0c650f294efc5512ff503f5f7da6eba1bb23a4e28853b69df651b50fb2d5ced403b837e15481a825a49c
6
+ metadata.gz: c7526df95cf7d7cd2a86d48c95ca57b4da54d9a6e94095318b0eefc5ec08dc37112072e0be0246b655715b21a0c593a0d49fbfc6cf44a6b5ad647ee6aa57188d
7
+ data.tar.gz: 92b7dd1398562e07cacb45a5b5c54aac29ee4e366b090dbc5fec31e44690d4a211872c6dfe3d0b93c5aa71de5bff3f39da8f82d933f26484516a1fe875c17fd1
@@ -9,6 +9,7 @@ class CreateUsers < ActiveRecord::Migration[5.1]
9
9
  t.string :first_name
10
10
  t.string :last_name
11
11
  t.string :status
12
+ t.string :login_id
12
13
 
13
14
  t.timestamps
14
15
  end
@@ -36,15 +36,32 @@ module CanvasSync
36
36
 
37
37
  private
38
38
 
39
- def self.perform_import(klass, database_column_names, rows, conflict_target)
39
+ def self.perform_import(klass, columns, rows, conflict_target)
40
40
  return if rows.length == 0
41
- database_column_names = database_column_names.dup
42
- klass.import(database_column_names, rows, validate: false, on_duplicate_key_update: {
41
+ columns = columns.dup
42
+ klass.import(columns, rows, validate: false, on_duplicate_key_update: {
43
43
  conflict_target: conflict_target,
44
- columns: database_column_names
44
+ condition: condition_sql(klass, columns),
45
+ columns: columns
45
46
  })
46
47
  end
47
48
 
49
+ # This method generates SQL that looks like:
50
+ # (users.sis_id, users.email) IS DISTINCT FROM (EXCLUDED.sis_id, EXCLUDED.email)
51
+ #
52
+ # This prevents activerecord-import from setting the `updated_at` column for
53
+ # rows that haven't actually changed. This allows you to query for rows that have changed
54
+ # by doing something like:
55
+ #
56
+ # started_at = Time.now
57
+ # run_the_users_sync!
58
+ # changed = User.where("updated_at >= ?", started_at)
59
+ def self.condition_sql(klass, columns)
60
+ columns_str = columns.map { |c| "#{klass.quoted_table_name}.#{c}" }.join(", ")
61
+ excluded_str = columns.map { |c| "EXCLUDED.#{c}" }.join(", ")
62
+ "(#{columns_str}) IS DISTINCT FROM (#{excluded_str})"
63
+ end
64
+
48
65
  def self.batch_size
49
66
  batch_size = ENV['BULK_IMPORTER_BATCH_SIZE'].to_i
50
67
  batch_size > 0 ? batch_size : DEFAULT_BATCH_SIZE
@@ -13,7 +13,8 @@ module CanvasSync
13
13
  email: :email,
14
14
  first_name: :first_name,
15
15
  last_name: :last_name,
16
- status: :status
16
+ status: :status,
17
+ login_id: :login_id
17
18
  }
18
19
 
19
20
  COURSES_CSV_MAPPING = {
@@ -1,3 +1,3 @@
1
1
  module CanvasSync
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -15,6 +15,7 @@ class CreateUsers < ActiveRecord::Migration[5.1]
15
15
  t.string :first_name
16
16
  t.string :last_name
17
17
  t.string :status
18
+ t.string :login_id
18
19
 
19
20
  t.timestamps
20
21
  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: 20170915210836) do
13
+ ActiveRecord::Schema.define(version: 20170918221413) do
14
14
 
15
15
  create_table "canvas_sync_job_logs", force: :cascade do |t|
16
16
  t.datetime "started_at"
@@ -18,6 +18,7 @@ ActiveRecord::Schema.define(version: 20170915210836) do
18
18
  t.string "exception"
19
19
  t.text "backtrace"
20
20
  t.string "job_class"
21
+ t.string "status"
21
22
  t.text "metadata"
22
23
  t.text "job_arguments"
23
24
  t.datetime "created_at", null: false
@@ -93,6 +94,7 @@ ActiveRecord::Schema.define(version: 20170915210836) do
93
94
  t.string "first_name"
94
95
  t.string "last_name"
95
96
  t.string "status"
97
+ t.string "login_id"
96
98
  t.datetime "created_at", null: false
97
99
  t.datetime "updated_at", null: false
98
100
  t.index ["canvas_user_id"], name: "index_users_on_canvas_user_id", unique: true
@@ -4239,4 +4239,153 @@ Migrating to CreateCanvasSyncJobLog (20170915210836)
4239
4239
  SELECT sql
4240
4240
  FROM sqlite_temp_master
4241
4241
  WHERE name='index_users_on_canvas_user_id' AND type='index'
4242
+ 
4243
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
4244
+  (0.1ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? [["key", "environment"]]
4245
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
4246
+  (0.1ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? [["key", "environment"]]
4247
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
4248
+  (0.1ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? [["key", "environment"]]
4249
+  (0.1ms) SELECT sqlite_version(*)
4250
+  (7.2ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)
4251
+  (1.1ms) CREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
4252
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
4253
+ Migrating to CreateEnrollments (20170905192509)
4254
+  (0.1ms) begin transaction
4255
+  (0.4ms) CREATE TABLE "enrollments" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "canvas_enrollment_id" bigint NOT NULL, "canvas_course_id" bigint, "course_sis_id" varchar, "canvas_user_id" bigint, "user_sis_id" varchar, "role" varchar, "role_id" integer, "canvas_section_id" bigint, "section_sis_id" varchar, "status" varchar, "base_role_type" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
4256
+  (0.1ms) CREATE UNIQUE INDEX "index_enrollments_on_canvas_enrollment_id" ON "enrollments" ("canvas_enrollment_id")
4257
+  (0.1ms)  SELECT sql
4258
+ FROM sqlite_master
4259
+ WHERE name='index_enrollments_on_canvas_enrollment_id' AND type='index'
4260
+ UNION ALL
4261
+ SELECT sql
4262
+ FROM sqlite_temp_master
4263
+ WHERE name='index_enrollments_on_canvas_enrollment_id' AND type='index'
4264
+ 
4265
+  (0.1ms) CREATE INDEX "index_enrollments_on_canvas_course_id" ON "enrollments" ("canvas_course_id")
4266
+  (0.1ms)  SELECT sql
4267
+ FROM sqlite_master
4268
+ WHERE name='index_enrollments_on_canvas_course_id' AND type='index'
4269
+ UNION ALL
4270
+ SELECT sql
4271
+ FROM sqlite_temp_master
4272
+ WHERE name='index_enrollments_on_canvas_course_id' AND type='index'
4273
+ 
4274
+  (0.1ms)  SELECT sql
4275
+ FROM sqlite_master
4276
+ WHERE name='index_enrollments_on_canvas_enrollment_id' AND type='index'
4277
+ UNION ALL
4278
+ SELECT sql
4279
+ FROM sqlite_temp_master
4280
+ WHERE name='index_enrollments_on_canvas_enrollment_id' AND type='index'
4281
+ 
4282
+  (0.1ms) CREATE INDEX "index_enrollments_on_canvas_user_id" ON "enrollments" ("canvas_user_id")
4283
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20170905192509"]]
4284
+  (1.3ms) commit transaction
4285
+ Migrating to CreateTerms (20170906193506)
4286
+  (0.1ms) begin transaction
4287
+  (0.4ms) CREATE TABLE "terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "canvas_term_id" integer NOT NULL, "name" varchar, "start_at" datetime, "end_at" datetime, "workflow_state" varchar, "grading_period_group_id" integer, "sis_id" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
4288
+  (0.1ms) CREATE UNIQUE INDEX "index_terms_on_canvas_term_id" ON "terms" ("canvas_term_id")
4289
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20170906193506"]]
4290
+  (1.4ms) commit transaction
4291
+ Migrating to CreateSections (20170906203438)
4292
+  (0.1ms) begin transaction
4293
+  (0.4ms) CREATE TABLE "sections" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "canvas_section_id" bigint NOT NULL, "sis_id" varchar, "canvas_course_id" bigint, "name" varchar, "status" varchar, "start_date" datetime, "end_date" datetime, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
4294
+  (0.1ms) CREATE UNIQUE INDEX "index_sections_on_canvas_section_id" ON "sections" ("canvas_section_id")
4295
+  (0.1ms)  SELECT sql
4296
+ FROM sqlite_master
4297
+ WHERE name='index_sections_on_canvas_section_id' AND type='index'
4298
+ UNION ALL
4299
+ SELECT sql
4300
+ FROM sqlite_temp_master
4301
+ WHERE name='index_sections_on_canvas_section_id' AND type='index'
4302
+ 
4303
+  (0.1ms) CREATE INDEX "index_sections_on_canvas_course_id" ON "sections" ("canvas_course_id")
4304
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20170906203438"]]
4305
+  (0.8ms) commit transaction
4306
+ Migrating to CreateCourses (20170914181345)
4307
+  (0.0ms) begin transaction
4308
+  (0.3ms) CREATE TABLE "courses" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "canvas_course_id" bigint NOT NULL, "sis_id" varchar, "short_name" varchar, "long_name" varchar, "status" varchar, "canvas_account_id" integer, "canvas_term_id" integer, "term_sis_id" integer, "start_date" datetime, "end_date" datetime, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
4309
+  (0.1ms) CREATE UNIQUE INDEX "index_courses_on_canvas_course_id" ON "courses" ("canvas_course_id")
4310
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20170914181345"]]
4311
+  (1.0ms) commit transaction
4312
+ Migrating to CreateCanvasSyncJobLog (20170915210836)
4313
+  (0.1ms) begin transaction
4314
+  (0.3ms) CREATE TABLE "canvas_sync_job_logs" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "started_at" datetime, "completed_at" datetime, "exception" varchar, "backtrace" text, "job_class" varchar, "status" varchar, "metadata" text, "job_arguments" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
4315
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20170915210836"]]
4316
+  (0.8ms) commit transaction
4317
+ Migrating to CreateUsers (20170918221413)
4318
+  (0.0ms) begin transaction
4319
+  (0.3ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "canvas_user_id" bigint NOT NULL, "sis_id" varchar, "email" varchar, "first_name" varchar, "last_name" varchar, "status" varchar, "login_id" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
4320
+  (0.1ms) CREATE UNIQUE INDEX "index_users_on_canvas_user_id" ON "users" ("canvas_user_id")
4321
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20170918221413"]]
4322
+  (1.0ms) commit transaction
4323
+ ActiveRecord::InternalMetadata Load (0.1ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", "environment"], ["LIMIT", 1]]
4324
+  (0.0ms) begin transaction
4325
+ SQL (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["key", "environment"], ["value", "development"], ["created_at", "2017-09-18 22:14:19.660824"], ["updated_at", "2017-09-18 22:14:19.660824"]]
4326
+  (1.0ms) commit transaction
4327
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
4328
+  (0.1ms)  SELECT sql
4329
+ FROM sqlite_master
4330
+ WHERE name='index_courses_on_canvas_course_id' AND type='index'
4331
+ UNION ALL
4332
+ SELECT sql
4333
+ FROM sqlite_temp_master
4334
+ WHERE name='index_courses_on_canvas_course_id' AND type='index'
4335
+ 
4336
+  (0.1ms)  SELECT sql
4337
+ FROM sqlite_master
4338
+ WHERE name='index_enrollments_on_canvas_user_id' AND type='index'
4339
+ UNION ALL
4340
+ SELECT sql
4341
+ FROM sqlite_temp_master
4342
+ WHERE name='index_enrollments_on_canvas_user_id' AND type='index'
4343
+ 
4344
+  (0.1ms)  SELECT sql
4345
+ FROM sqlite_master
4346
+ WHERE name='index_enrollments_on_canvas_course_id' AND type='index'
4347
+ UNION ALL
4348
+ SELECT sql
4349
+ FROM sqlite_temp_master
4350
+ WHERE name='index_enrollments_on_canvas_course_id' AND type='index'
4351
+ 
4352
+  (0.1ms)  SELECT sql
4353
+ FROM sqlite_master
4354
+ WHERE name='index_enrollments_on_canvas_enrollment_id' AND type='index'
4355
+ UNION ALL
4356
+ SELECT sql
4357
+ FROM sqlite_temp_master
4358
+ WHERE name='index_enrollments_on_canvas_enrollment_id' AND type='index'
4359
+ 
4360
+  (0.1ms)  SELECT sql
4361
+ FROM sqlite_master
4362
+ WHERE name='index_sections_on_canvas_course_id' AND type='index'
4363
+ UNION ALL
4364
+ SELECT sql
4365
+ FROM sqlite_temp_master
4366
+ WHERE name='index_sections_on_canvas_course_id' AND type='index'
4367
+ 
4368
+  (0.1ms)  SELECT sql
4369
+ FROM sqlite_master
4370
+ WHERE name='index_sections_on_canvas_section_id' AND type='index'
4371
+ UNION ALL
4372
+ SELECT sql
4373
+ FROM sqlite_temp_master
4374
+ WHERE name='index_sections_on_canvas_section_id' AND type='index'
4375
+ 
4376
+  (0.1ms)  SELECT sql
4377
+ FROM sqlite_master
4378
+ WHERE name='index_terms_on_canvas_term_id' AND type='index'
4379
+ UNION ALL
4380
+ SELECT sql
4381
+ FROM sqlite_temp_master
4382
+ WHERE name='index_terms_on_canvas_term_id' AND type='index'
4383
+ 
4384
+  (0.1ms)  SELECT sql
4385
+ FROM sqlite_master
4386
+ WHERE name='index_users_on_canvas_user_id' AND type='index'
4387
+ UNION ALL
4388
+ SELECT sql
4389
+ FROM sqlite_temp_master
4390
+ WHERE name='index_users_on_canvas_user_id' AND type='index'
4242
4391
  
Binary file
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.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Collings
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-15 00:00:00.000000000 Z
11
+ date: 2017-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -346,13 +346,12 @@ files:
346
346
  - spec/dummy/config/routes.rb
347
347
  - spec/dummy/config/secrets.yml
348
348
  - spec/dummy/db/development.sqlite3
349
- - spec/dummy/db/migrate/20170831221129_create_users.rb
350
349
  - spec/dummy/db/migrate/20170905192509_create_enrollments.rb
351
350
  - spec/dummy/db/migrate/20170906193506_create_terms.rb
352
351
  - spec/dummy/db/migrate/20170906203438_create_sections.rb
353
352
  - spec/dummy/db/migrate/20170914181345_create_courses.rb
353
+ - spec/dummy/db/migrate/20170918221413_create_users.rb
354
354
  - spec/dummy/db/schema.rb
355
- - spec/dummy/db/test.sqlite3
356
355
  - spec/dummy/log/development.log
357
356
  - spec/dummy/log/test.log
358
357
  - spec/factories/course_factory.rb
@@ -430,13 +429,12 @@ test_files:
430
429
  - spec/dummy/config/routes.rb
431
430
  - spec/dummy/config/secrets.yml
432
431
  - spec/dummy/db/development.sqlite3
433
- - spec/dummy/db/migrate/20170831221129_create_users.rb
434
432
  - spec/dummy/db/migrate/20170905192509_create_enrollments.rb
435
433
  - spec/dummy/db/migrate/20170906193506_create_terms.rb
436
434
  - spec/dummy/db/migrate/20170906203438_create_sections.rb
437
435
  - spec/dummy/db/migrate/20170914181345_create_courses.rb
436
+ - spec/dummy/db/migrate/20170918221413_create_users.rb
438
437
  - spec/dummy/db/schema.rb
439
- - spec/dummy/db/test.sqlite3
440
438
  - spec/dummy/log/development.log
441
439
  - spec/dummy/log/test.log
442
440
  - spec/factories/course_factory.rb
Binary file