algoliasearch-rails 2.3.0 → 2.3.2

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
  SHA256:
3
- metadata.gz: 91a3c57ba564afcd15833841c0c4dad105b1889179281b43e59a1adcb5c3acd2
4
- data.tar.gz: d8bdac6cdf53cb6f095e1d485c6ceff1d94a17c6d649d76cefd29dca37d65172
3
+ metadata.gz: 2f1f301750d7affc346eea8252c11e98722a8ac4c82be59fb8a248a69fa459ce
4
+ data.tar.gz: ce9e1536025efd0f881b6e45be3db203d7dc0eafc6f4b0d07cf8f9b8aea95761
5
5
  SHA512:
6
- metadata.gz: 13fe3ebce7b706de4324f0ee1f5fea8fdcfb6913445cc56a24a337868ac9f98edd173b5559a58921b73156d1dfe5d56fd3bd302666923966e5a1c4328369b5ec
7
- data.tar.gz: f6237c40c513bacdb78ebd307668c0ae478c4e20f600a5d9ac10ca164ab2082e9515d9061177e5b93faf9ffebafbe4c864f80851c9466ac23565f4a7dadc83b4
6
+ metadata.gz: d9de7d8769fc9c19adbfbe70cef64e643c5d25d55774962d041962f570826566dd518a550fd23f73f4293bcdf5e1d048af354d2c9dc1c41ebe574dac64b5d996
7
+ data.tar.gz: '05787dce080a885c00ae4efdff6a9b4f26e2109979845ec8405d78f27f5c9757c30e77b814cb0f6957b49f8787cd468df15c8c8369091d80f39adc83e33f1adf'
data/CHANGELOG.MD CHANGED
@@ -2,7 +2,16 @@
2
2
 
3
3
  ## [Unreleased](https://github.com/algolia/algoliasearch-rails/compare/2.2.1...master)
4
4
 
5
- ## [2.2.2](https://github.com/algolia/algoliasearch-rails/compare/2.2.2...2.3.0)
5
+ ## [2.3.2](https://github.com/algolia/algoliasearch-rails/compare/2.3.1...2.3.2)
6
+ ### Added
7
+ * Support for Pagy pagination provider [`#443`](https://github.com/algolia/algoliasearch-rails/pull/443)
8
+
9
+ ## [2.3.1](https://github.com/algolia/algoliasearch-rails/compare/2.3.0...2.3.1)
10
+ ### Added
11
+ * Allow ActiveJob queue configuration [`#439`](https://github.com/algolia/algoliasearch-rails/pull/439)
12
+ * allow to configure user agent and other default options [`#438`](https://github.com/algolia/algoliasearch-rails/pull/438)
13
+
14
+ ## [2.3.0](https://github.com/algolia/algoliasearch-rails/compare/2.2.2...2.3.0)
6
15
  ### Fixed
7
16
  * bugfix: don't consider objectID changed when using custom ID through method [`#436`](https://github.com/algolia/algoliasearch-rails/pull/436)
8
17
 
data/Gemfile CHANGED
@@ -34,5 +34,6 @@ end
34
34
  group :test, :development do
35
35
  gem 'will_paginate', '>= 2.3.15'
36
36
  gem 'kaminari', '< 1'
37
+ gem 'pagy'
37
38
  end
38
39
 
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
33
33
  "lib/algoliasearch/configuration.rb",
34
34
  "lib/algoliasearch/pagination.rb",
35
35
  "lib/algoliasearch/pagination/kaminari.rb",
36
+ "lib/algoliasearch/pagination/pagy.rb",
36
37
  "lib/algoliasearch/pagination/will_paginate.rb",
37
38
  "lib/algoliasearch/railtie.rb",
38
39
  "lib/algoliasearch/tasks/algoliasearch.rake",
@@ -81,6 +82,7 @@ Gem::Specification.new do |s|
81
82
  s.add_runtime_dependency(%q<algolia>, ["< 3.0.0"])
82
83
  s.add_development_dependency(%q<will_paginate>, [">= 2.3.15"])
83
84
  s.add_development_dependency(%q<kaminari>, [">= 0"])
85
+ s.add_development_dependency(%q<pagy>, [">= 0"])
84
86
  s.add_development_dependency "rake"
85
87
  s.add_development_dependency "rdoc"
86
88
  else
@@ -1,6 +1,6 @@
1
1
  module AlgoliaSearch
2
2
  class AlgoliaJob < ::ActiveJob::Base
3
- queue_as :algoliasearch
3
+ queue_as { AlgoliaSearch.configuration[:queue_name] }
4
4
 
5
5
  def perform(record, method)
6
6
  record.send(method)
@@ -1,5 +1,10 @@
1
1
  module AlgoliaSearch
2
2
  module Configuration
3
+ REQUIRED_CONFIGURATION = {
4
+ user_agent: "Algolia for Rails (#{AlgoliaSearch::VERSION}); Rails (#{defined?(::Rails::VERSION::STRING) ? ::Rails::VERSION::STRING : 'unknown'})",
5
+ symbolize_keys: false
6
+ }
7
+
3
8
  def initialize
4
9
  @client = nil
5
10
  end
@@ -9,10 +14,11 @@ module AlgoliaSearch
9
14
  end
10
15
 
11
16
  def configuration=(configuration)
12
- @@configuration = configuration.merge(
13
- :user_agent => "Algolia for Rails (#{AlgoliaSearch::VERSION}); Rails (#{Rails::VERSION::STRING})",
14
- :symbolize_keys => false
15
- )
17
+ user_agent = [REQUIRED_CONFIGURATION[:user_agent], configuration[:append_to_user_agent]].compact.join('; ')
18
+ @@configuration = default_configuration
19
+ .merge(configuration)
20
+ .merge(REQUIRED_CONFIGURATION)
21
+ .merge({ user_agent: user_agent })
16
22
  end
17
23
 
18
24
  def client_opts
@@ -34,5 +40,11 @@ module AlgoliaSearch
34
40
  def setup_client
35
41
  @client = Algolia::Search::Client.new(Algolia::Search::Config.new(@@configuration), client_opts)
36
42
  end
43
+
44
+ def default_configuration
45
+ {
46
+ queue_name: 'algoliasearch'
47
+ }
48
+ end
37
49
  end
38
50
  end
@@ -0,0 +1,22 @@
1
+ unless defined? Pagy
2
+ raise(AlgoliaSearch::BadConfiguration, "AlgoliaSearch: Please add 'pagy' to your Gemfile to use Pagy pagination backend")
3
+ end
4
+
5
+ module AlgoliaSearch
6
+ module Pagination
7
+ class Pagy
8
+ def self.create(results, total_hits, options = {})
9
+ vars = {
10
+ count: total_hits,
11
+ page: options[:page],
12
+ items: options[:per_page]
13
+ }
14
+
15
+ pagy = ::Pagy.new(vars)
16
+ [pagy, results]
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+
@@ -3,6 +3,7 @@ module AlgoliaSearch
3
3
 
4
4
  autoload :WillPaginate, 'algoliasearch/pagination/will_paginate'
5
5
  autoload :Kaminari, 'algoliasearch/pagination/kaminari'
6
+ autoload :Pagy, 'algoliasearch/pagination/pagy'
6
7
 
7
8
  def self.create(results, total_hits, options = {})
8
9
  return results if AlgoliaSearch.configuration[:pagination_backend].nil?
@@ -1,3 +1,3 @@
1
1
  module AlgoliaSearch
2
- VERSION = '2.3.0'
2
+ VERSION = '2.3.2'
3
3
  end
@@ -683,7 +683,7 @@ module AlgoliaSearch
683
683
 
684
684
  def algolia_search(q, params = {})
685
685
  if AlgoliaSearch.configuration[:pagination_backend]
686
- # kaminari and will_paginate start pagination at 1, Algolia starts at 0
686
+ # kaminari, will_paginate, and pagy start pagination at 1, Algolia starts at 0
687
687
  params[:page] = (params.delete('page') || params.delete(:page)).to_i
688
688
  params[:page] -= 1 if params[:page].to_i > 0
689
689
  end
data/spec/spec_helper.rb CHANGED
@@ -15,6 +15,8 @@ raise "missing ALGOLIA_APPLICATION_ID or ALGOLIA_API_KEY environment variables"
15
15
 
16
16
  Thread.current[:algolia_hosts] = nil
17
17
 
18
+ GlobalID.app = 'algoiasearch-rails'
19
+
18
20
  RSpec.configure do |c|
19
21
  c.mock_with :rspec
20
22
  c.filter_run :focus => true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: algoliasearch-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Algolia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-12 00:00:00.000000000 Z
11
+ date: 2024-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pagy
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rake
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -117,6 +131,7 @@ files:
117
131
  - lib/algoliasearch/configuration.rb
118
132
  - lib/algoliasearch/pagination.rb
119
133
  - lib/algoliasearch/pagination/kaminari.rb
134
+ - lib/algoliasearch/pagination/pagy.rb
120
135
  - lib/algoliasearch/pagination/will_paginate.rb
121
136
  - lib/algoliasearch/railtie.rb
122
137
  - lib/algoliasearch/tasks/algoliasearch.rake