canvas_sync 0.16.3 → 0.16.4
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 +4 -4
- data/lib/canvas_sync.rb +1 -1
- data/lib/canvas_sync/concerns/api_syncable.rb +27 -0
- data/lib/canvas_sync/version.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: ddf6a257acf95c92ba99a6d03c9bcdd99ba1a8ff
         | 
| 4 | 
            +
              data.tar.gz: f10e8f91a225462545354a24daaf006a170bd90d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: cde3a3a534316a0faa535347a6c71aa63ab46c5cc5d9c21b01512bb623bed7f6b34fc7da38de345fefcf238cc44f0423f849dd08aa8f57f292472838aa6f7d0c
         | 
| 7 | 
            +
              data.tar.gz: 2e1b8217af038166f60afe4032f0f1ec806761fb81d5727aec57540919146335f7a28292e8e81ba87220eb2d687325b8145be798ed6a29b07aaad0cd6e3b56f4
         | 
    
        data/lib/canvas_sync.rb
    CHANGED
    
    | @@ -132,7 +132,7 @@ module CanvasSync | |
| 132 132 | 
             
                  duped_job_chain[:global_options][:fork_path] ||= []
         | 
| 133 133 | 
             
                  duped_job_chain[:global_options][:fork_keys] ||= []
         | 
| 134 134 | 
             
                  duped_job_chain[:global_options][:fork_path] << job_log.job_id
         | 
| 135 | 
            -
                  duped_job_chain[:global_options][:fork_keys] << keys
         | 
| 135 | 
            +
                  duped_job_chain[:global_options][:fork_keys] << keys.map(&:to_s)
         | 
| 136 136 | 
             
                  duped_job_chain[:global_options][:on_failure] ||= 'CanvasSync::Jobs::ForkGather.handle_branch_error'
         | 
| 137 137 | 
             
                  sub_items = yield duped_job_chain
         | 
| 138 138 | 
             
                  sub_count = sub_items.respond_to?(:count) ? sub_items.count : sub_items
         | 
| @@ -29,6 +29,33 @@ module CanvasSync::Concerns | |
| 29 29 | 
             
                    end
         | 
| 30 30 | 
             
                  end
         | 
| 31 31 |  | 
| 32 | 
            +
                  def bulk_sync_from_api_result(api_array, conflict_target: :canvas_id, import_args: {}, all_pages: true, batch_size: 1000)
         | 
| 33 | 
            +
                    columns = api_sync_options.keys
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                    update_conditions = {
         | 
| 36 | 
            +
                      condition: Importers::BulkImporter.condition_sql(self, columns),
         | 
| 37 | 
            +
                      columns: columns,
         | 
| 38 | 
            +
                    }
         | 
| 39 | 
            +
                    update_conditions[:conflict_target] = conflict_target if conflict_target.present?
         | 
| 40 | 
            +
                    options = { validate: false, on_duplicate_key_update: update_conditions }.merge(import_args)
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                    if all_pages
         | 
| 43 | 
            +
                      batcher = BatchProcessor.new(of: batch_size) do |batch|
         | 
| 44 | 
            +
                        import(columns, batch, options)
         | 
| 45 | 
            +
                      end
         | 
| 46 | 
            +
                      api_array.all_pages_each do |api_item|
         | 
| 47 | 
            +
                        item = new.assign_from_api_params(api_items)
         | 
| 48 | 
            +
                        batcher << item
         | 
| 49 | 
            +
                      end
         | 
| 50 | 
            +
                      batcher.flush
         | 
| 51 | 
            +
                    else
         | 
| 52 | 
            +
                      items = api_array.map do |api_item|
         | 
| 53 | 
            +
                        new.assign_from_api_params(api_items)
         | 
| 54 | 
            +
                      end
         | 
| 55 | 
            +
                      import(columns, batch, options)
         | 
| 56 | 
            +
                    end
         | 
| 57 | 
            +
                  end
         | 
| 58 | 
            +
             | 
| 32 59 | 
             
                  def api_sync_options=(opts)
         | 
| 33 60 | 
             
                    @api_sync_options = opts
         | 
| 34 61 | 
             
                  end
         | 
    
        data/lib/canvas_sync/version.rb
    CHANGED
    
    
    
        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.16. | 
| 4 | 
            +
              version: 0.16.4
         | 
| 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-09- | 
| 11 | 
            +
            date: 2020-09-29 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         |