canvas_sync 0.1.7 → 0.1.8
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 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 450c9dd5440a29b40915b904cbbbe5eeeeff1c5d
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 76035ff5b19e381ff046e6a57eec80943bb43254
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: eabefd522ae7150d7e9d5774440670fc647084ebad7786d3bd1b57dee0025d7a77607ffc923e16d76969986f29c6c47957042d3cf8873713676f284ac78d0aa0
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 202029add66cc446630ba15c2a5816adbcdd2971085532d977e8cce40f365c5678d636833c9dd137b667bc18d27d25201d48da3b1ce7bb05f8c92b6003c8aee7
         
     | 
| 
         @@ -13,16 +13,25 @@ module CanvasSync 
     | 
|
| 
       13 
13 
     | 
    
         
             
                  # @param klass [Object] e.g., User
         
     | 
| 
       14 
14 
     | 
    
         
             
                  # @param conflict_target [Symbol] represents the database column that will determine if we need to update
         
     | 
| 
       15 
15 
     | 
    
         
             
                  #   or insert a given row. e.g.,: canvas_user_id
         
     | 
| 
      
 16 
     | 
    
         
            +
                  # @param exclude_duplicates [Boolean] importing will break if the file has any duplicate rows. Set this
         
     | 
| 
      
 17 
     | 
    
         
            +
                  #   to true in order to have the bulk importer filter those out.
         
     | 
| 
       16 
18 
     | 
    
         
             
                  # @yieldparam [Array] row if a block is passed in it will yield the current row from the CSV.
         
     | 
| 
       17 
19 
     | 
    
         
             
                  #   This can be used if you need to filter or massage the data in any way.
         
     | 
| 
       18 
     | 
    
         
            -
                  def self.import(report_file_path, mapping, klass, conflict_target)
         
     | 
| 
      
 20 
     | 
    
         
            +
                  def self.import(report_file_path, mapping, klass, conflict_target, exclude_duplicates=false)
         
     | 
| 
       19 
21 
     | 
    
         
             
                    csv_column_names = mapping.keys
         
     | 
| 
       20 
22 
     | 
    
         
             
                    database_column_names = mapping.values
         
     | 
| 
       21 
23 
     | 
    
         
             
                    rows = []
         
     | 
| 
      
 24 
     | 
    
         
            +
                    row_ids = {}
         
     | 
| 
       22 
25 
     | 
    
         | 
| 
       23 
26 
     | 
    
         
             
                    CSV.foreach(report_file_path, headers: true, header_converters: :symbol) do |row|
         
     | 
| 
       24 
27 
     | 
    
         
             
                      row = yield(row) if block_given?
         
     | 
| 
       25 
28 
     | 
    
         
             
                      next if row.nil?
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                      if exclude_duplicates
         
     | 
| 
      
 31 
     | 
    
         
            +
                        next if row_ids[row[conflict_target]]
         
     | 
| 
      
 32 
     | 
    
         
            +
                        row_ids[row[conflict_target]] = true
         
     | 
| 
      
 33 
     | 
    
         
            +
                      end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
       26 
35 
     | 
    
         
             
                      rows << csv_column_names.map { |column| row[column] }
         
     | 
| 
       27 
36 
     | 
    
         | 
| 
       28 
37 
     | 
    
         
             
                      if rows.length >= batch_size
         
     | 
| 
         @@ -92,16 +92,12 @@ module CanvasSync 
     | 
|
| 
       92 
92 
     | 
    
         
             
                  end
         
     | 
| 
       93 
93 
     | 
    
         | 
| 
       94 
94 
     | 
    
         
             
                  def self.process_users(report_file_path)
         
     | 
| 
       95 
     | 
    
         
            -
                     
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
                      next nil if rows[row[:canvas_user_id]]
         
     | 
| 
       102 
     | 
    
         
            -
                      rows[row[:canvas_user_id]] = true
         
     | 
| 
       103 
     | 
    
         
            -
                      row
         
     | 
| 
       104 
     | 
    
         
            -
                    end
         
     | 
| 
      
 95 
     | 
    
         
            +
                    CanvasSync::Importers::BulkImporter.import(
         
     | 
| 
      
 96 
     | 
    
         
            +
                      report_file_path,
         
     | 
| 
      
 97 
     | 
    
         
            +
                      USERS_CSV_MAPPING,
         
     | 
| 
      
 98 
     | 
    
         
            +
                      User,
         
     | 
| 
      
 99 
     | 
    
         
            +
                      :canvas_user_id,
         
     | 
| 
      
 100 
     | 
    
         
            +
                      true)
         
     | 
| 
       105 
101 
     | 
    
         
             
                  end
         
     | 
| 
       106 
102 
     | 
    
         | 
| 
       107 
103 
     | 
    
         
             
                  def self.process_courses(report_file_path)
         
     | 
| 
         @@ -109,7 +105,12 @@ module CanvasSync 
     | 
|
| 
       109 
105 
     | 
    
         
             
                  end
         
     | 
| 
       110 
106 
     | 
    
         | 
| 
       111 
107 
     | 
    
         
             
                  def self.process_enrollments(report_file_path)
         
     | 
| 
       112 
     | 
    
         
            -
                    CanvasSync::Importers::BulkImporter.import( 
     | 
| 
      
 108 
     | 
    
         
            +
                    CanvasSync::Importers::BulkImporter.import(
         
     | 
| 
      
 109 
     | 
    
         
            +
                      report_file_path,
         
     | 
| 
      
 110 
     | 
    
         
            +
                      ENROLLMENTS_CSV_MAPPING,
         
     | 
| 
      
 111 
     | 
    
         
            +
                      Enrollment,
         
     | 
| 
      
 112 
     | 
    
         
            +
                      :canvas_enrollment_id,
         
     | 
| 
      
 113 
     | 
    
         
            +
                      true)
         
     | 
| 
       113 
114 
     | 
    
         
             
                  end
         
     | 
| 
       114 
115 
     | 
    
         | 
| 
       115 
116 
     | 
    
         
             
                  def self.process_sections(report_file_path)
         
     | 
    
        data/lib/canvas_sync/version.rb
    CHANGED
    
    
| 
         Binary file 
     | 
    
        data/spec/dummy/log/test.log
    CHANGED
    
    | 
         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. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.8
         
     | 
| 
       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- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-09-19 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -352,6 +352,7 @@ files: 
     | 
|
| 
       352 
352 
     | 
    
         
             
            - spec/dummy/db/migrate/20170914181345_create_courses.rb
         
     | 
| 
       353 
353 
     | 
    
         
             
            - spec/dummy/db/migrate/20170918221413_create_users.rb
         
     | 
| 
       354 
354 
     | 
    
         
             
            - spec/dummy/db/schema.rb
         
     | 
| 
      
 355 
     | 
    
         
            +
            - spec/dummy/db/test.sqlite3
         
     | 
| 
       355 
356 
     | 
    
         
             
            - spec/dummy/log/development.log
         
     | 
| 
       356 
357 
     | 
    
         
             
            - spec/dummy/log/test.log
         
     | 
| 
       357 
358 
     | 
    
         
             
            - spec/factories/course_factory.rb
         
     | 
| 
         @@ -435,6 +436,7 @@ test_files: 
     | 
|
| 
       435 
436 
     | 
    
         
             
            - spec/dummy/db/migrate/20170914181345_create_courses.rb
         
     | 
| 
       436 
437 
     | 
    
         
             
            - spec/dummy/db/migrate/20170918221413_create_users.rb
         
     | 
| 
       437 
438 
     | 
    
         
             
            - spec/dummy/db/schema.rb
         
     | 
| 
      
 439 
     | 
    
         
            +
            - spec/dummy/db/test.sqlite3
         
     | 
| 
       438 
440 
     | 
    
         
             
            - spec/dummy/log/development.log
         
     | 
| 
       439 
441 
     | 
    
         
             
            - spec/dummy/log/test.log
         
     | 
| 
       440 
442 
     | 
    
         
             
            - spec/factories/course_factory.rb
         
     |