workarea-api-admin 4.5.0 → 4.5.6
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/app/controllers/workarea/api/admin/recommendation_settings_controller.rb +1 -1
- data/app/models/workarea/api/admin/date_filtering.rb +0 -3
- data/lib/workarea/api/admin.rb +1 -0
- data/lib/workarea/api/admin/date_indexes.rb +23 -0
- data/lib/workarea/api/admin/engine.rb +2 -0
- data/test/integration/workarea/api/admin/recommendation_settings_integration_test.rb +14 -0
- data/workarea-api-admin.gemspec +2 -2
- metadata +8 -7
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 73b13580adeadec266393c807ff389f70684dd538a08744c21d926d1b1a70662
         | 
| 4 | 
            +
              data.tar.gz: c06a7dbe0e69cdf10f5cee49e65087b19bfa390861ee7f1fb39c7b15eafebf35
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: e7b53927b51128022e2404f58f75f811a1332104374e6cb802775c09f187cd5da79d32fae950c5e93d319def28bf0eebf82b1a4f0a2b1a10e9916e74ed571dbc
         | 
| 7 | 
            +
              data.tar.gz: 9a2c721e8b8a25fc602eb5dd46c3c4ab4b1805aee7b344ce53f49c4cc82efb79a1b0ebdb90559ec5f92d72bebe62b103de94a63ee7b65d30f180bc28051c27fe
         | 
| @@ -114,7 +114,7 @@ module Workarea | |
| 114 114 | 
             
                    private
         | 
| 115 115 |  | 
| 116 116 | 
             
                    def find_recommendation_settings
         | 
| 117 | 
            -
                      @recommendation_settings = Recommendation::Settings. | 
| 117 | 
            +
                      @recommendation_settings = Recommendation::Settings.find_or_initialize_by(id: params[:product_id])
         | 
| 118 118 | 
             
                    end
         | 
| 119 119 | 
             
                  end
         | 
| 120 120 | 
             
                end
         | 
| @@ -4,9 +4,6 @@ module Workarea | |
| 4 4 | 
             
                  module DateFiltering
         | 
| 5 5 | 
             
                    extend ActiveSupport::Concern
         | 
| 6 6 | 
             
                    included do
         | 
| 7 | 
            -
                      index({ updated_at: 1 })
         | 
| 8 | 
            -
                      index({ created_at: 1 })
         | 
| 9 | 
            -
             | 
| 10 7 | 
             
                      scope :by_updated_at, ->(starts_at:, ends_at:) do
         | 
| 11 8 | 
             
                        query = criteria
         | 
| 12 9 | 
             
                        query = query.where(:updated_at.gte => starts_at) unless starts_at.nil?
         | 
    
        data/lib/workarea/api/admin.rb
    CHANGED
    
    
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
             | 
| 2 | 
            +
            module Workarea
         | 
| 3 | 
            +
              module Api
         | 
| 4 | 
            +
                module Admin
         | 
| 5 | 
            +
                  module DateIndexes
         | 
| 6 | 
            +
                    extend self
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                    # We do this separately from the DateFiltering module to ensure
         | 
| 9 | 
            +
                    # this happens after a model has defined all of its normal indexes. This
         | 
| 10 | 
            +
                    # prevents the date filtering indexes from applying before explicity
         | 
| 11 | 
            +
                    # defined indexes for models that could include options like a TTL.
         | 
| 12 | 
            +
                    def load
         | 
| 13 | 
            +
                      ::Mongoid.models.each do |model|
         | 
| 14 | 
            +
                        if model < ApplicationDocument
         | 
| 15 | 
            +
                          model.index({ updated_at: 1 })
         | 
| 16 | 
            +
                          model.index({ created_at: 1 })
         | 
| 17 | 
            +
                        end
         | 
| 18 | 
            +
                      end
         | 
| 19 | 
            +
                    end
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
            end
         | 
| @@ -14,10 +14,12 @@ module Workarea | |
| 14 14 |  | 
| 15 15 | 
             
                    config.after_initialize do
         | 
| 16 16 | 
             
                      Workarea::Api::Admin::Swagger.generate!
         | 
| 17 | 
            +
                      Workarea::Api::Admin::DateIndexes.load
         | 
| 17 18 | 
             
                    end
         | 
| 18 19 |  | 
| 19 20 | 
             
                    config.to_prepare do
         | 
| 20 21 | 
             
                      ApplicationDocument.include(DateFiltering)
         | 
| 22 | 
            +
                      Workarea::Api::Admin::DateIndexes.load
         | 
| 21 23 | 
             
                    end
         | 
| 22 24 | 
             
                  end
         | 
| 23 25 | 
             
                end
         | 
| @@ -35,6 +35,20 @@ module Workarea | |
| 35 35 |  | 
| 36 36 | 
             
                      assert_equal(['foo'], recommendation_settings.reload.product_ids)
         | 
| 37 37 | 
             
                    end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                    def test_unpersisted_recommendation_settings
         | 
| 40 | 
            +
                      get admin_api.product_recommendation_settings_path(@product.id)
         | 
| 41 | 
            +
                      result = JSON.parse(response.body)['recommendation_settings']
         | 
| 42 | 
            +
                      assert_equal(@product.id, result['_id'])
         | 
| 43 | 
            +
                      assert_equal(0, Recommendation::Settings.count)
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                      patch admin_api.product_recommendation_settings_path(@product.id),
         | 
| 46 | 
            +
                        params: { recommendation_settings: { product_ids: ['foo'] } }
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                      assert_equal(1, Recommendation::Settings.count)
         | 
| 49 | 
            +
                      assert_equal(@product.id, Recommendation::Settings.first.id)
         | 
| 50 | 
            +
                      assert_equal(['foo'], Recommendation::Settings.first.product_ids)
         | 
| 51 | 
            +
                    end
         | 
| 38 52 | 
             
                  end
         | 
| 39 53 | 
             
                end
         | 
| 40 54 | 
             
              end
         | 
    
        data/workarea-api-admin.gemspec
    CHANGED
    
    | @@ -14,6 +14,6 @@ Gem::Specification.new do |s| | |
| 14 14 |  | 
| 15 15 | 
             
              s.required_ruby_version = '>= 2.3.0'
         | 
| 16 16 |  | 
| 17 | 
            -
              s.add_dependency 'workarea', '~> 3.x', '>= 3. | 
| 18 | 
            -
              s.add_dependency 'responders', '~>  | 
| 17 | 
            +
              s.add_dependency 'workarea', '~> 3.x', '>= 3.5.x'
         | 
| 18 | 
            +
              s.add_dependency 'responders', '~> 3.0.0'
         | 
| 19 19 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: workarea-api-admin
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 4.5. | 
| 4 | 
            +
              version: 4.5.6
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Ben Crouse
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2020-12-02 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: workarea
         | 
| @@ -19,7 +19,7 @@ dependencies: | |
| 19 19 | 
             
                    version: 3.x
         | 
| 20 20 | 
             
                - - ">="
         | 
| 21 21 | 
             
                  - !ruby/object:Gem::Version
         | 
| 22 | 
            -
                    version: 3. | 
| 22 | 
            +
                    version: 3.5.x
         | 
| 23 23 | 
             
              type: :runtime
         | 
| 24 24 | 
             
              prerelease: false
         | 
| 25 25 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| @@ -29,21 +29,21 @@ dependencies: | |
| 29 29 | 
             
                    version: 3.x
         | 
| 30 30 | 
             
                - - ">="
         | 
| 31 31 | 
             
                  - !ruby/object:Gem::Version
         | 
| 32 | 
            -
                    version: 3. | 
| 32 | 
            +
                    version: 3.5.x
         | 
| 33 33 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 34 34 | 
             
              name: responders
         | 
| 35 35 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 36 36 | 
             
                requirements:
         | 
| 37 37 | 
             
                - - "~>"
         | 
| 38 38 | 
             
                  - !ruby/object:Gem::Version
         | 
| 39 | 
            -
                    version:  | 
| 39 | 
            +
                    version: 3.0.0
         | 
| 40 40 | 
             
              type: :runtime
         | 
| 41 41 | 
             
              prerelease: false
         | 
| 42 42 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 43 43 | 
             
                requirements:
         | 
| 44 44 | 
             
                - - "~>"
         | 
| 45 45 | 
             
                  - !ruby/object:Gem::Version
         | 
| 46 | 
            -
                    version:  | 
| 46 | 
            +
                    version: 3.0.0
         | 
| 47 47 | 
             
            description: This provides an admin JSON REST API for the Workarea Commerce Platform.
         | 
| 48 48 | 
             
              Useful for managing the site, 3rd party integrations, etc.
         | 
| 49 49 | 
             
            email:
         | 
| @@ -102,6 +102,7 @@ files: | |
| 102 102 | 
             
            - config/locales/en.yml
         | 
| 103 103 | 
             
            - config/routes.rb
         | 
| 104 104 | 
             
            - lib/workarea/api/admin.rb
         | 
| 105 | 
            +
            - lib/workarea/api/admin/date_indexes.rb
         | 
| 105 106 | 
             
            - lib/workarea/api/admin/engine.rb
         | 
| 106 107 | 
             
            - lib/workarea/api/admin/swagger.rb
         | 
| 107 108 | 
             
            - test/documentation/workarea/api/admin/categories_documentation_test.rb
         | 
| @@ -250,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 250 251 | 
             
                - !ruby/object:Gem::Version
         | 
| 251 252 | 
             
                  version: '0'
         | 
| 252 253 | 
             
            requirements: []
         | 
| 253 | 
            -
            rubygems_version: 3.0. | 
| 254 | 
            +
            rubygems_version: 3.0.3
         | 
| 254 255 | 
             
            signing_key: 
         | 
| 255 256 | 
             
            specification_version: 4
         | 
| 256 257 | 
             
            summary: Admin JSON REST API for the Workarea Commerce Platform
         |