audiences 1.0.2 → 1.0.3

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
  SHA256:
3
- metadata.gz: 4af455b618eb475abafc8af9308a208193b7ba2dc90e1bdb06ace775a6187577
4
- data.tar.gz: e5c9e37d32d7ded3e324d3d17cbb293d93809c94dcf05f3104511f3f46af364c
3
+ metadata.gz: db54cba8b15c751dd4103cb6941fb5dfcbdf3c2094a91a57233f4ee768b06e5c
4
+ data.tar.gz: bef9487c0a68472e81ed365b902ceff656fb6c789c53fe6b36bbcadac5b80d59
5
5
  SHA512:
6
- metadata.gz: 4a9c2bddbd35c72e69423d069e83c7c474a9b7969049bc474466768233e526454accd14097ea83dea2de9384d1ed821d6140f43cd9ddb8f10e0e0e9ad07b23dc
7
- data.tar.gz: 56e5af91a67d7838b0ae1305b505482dab15e9c930eb2ffad8051bec6e0f1cb6d4ecee0a5e4da2eb27fd6c21d34e26f285ff919e870f06b83a5f22517eeff351
6
+ metadata.gz: 4ec464d9f638ebee06c02bf523181db448449df899086e9a6c66de38d537711bef47f8bd58cd5291aa6ac622e733057fd159702473708bde591ba2bbe6715e0b
7
+ data.tar.gz: 22761b14b02f2ed98f13b63f2356a39c7d5dc62f0cbfbf3cb48f6c6b433c8f0fa6a1a027cde1ae9c5baba343785509d467613f10314a4ba85d20a8e89acb7594
@@ -10,7 +10,8 @@ module Audiences
10
10
  attrs = resources.map do |data|
11
11
  { user_id: data["id"], data: data, created_at: Time.current, updated_at: Time.current }
12
12
  end
13
- upsert_all(attrs) # rubocop:disable Rails/SkipsModelValidations
13
+ unique_by = :user_id if connection.supports_insert_conflict_target?
14
+ upsert_all(attrs, unique_by: unique_by) # rubocop:disable Rails/SkipsModelValidations
14
15
  where(user_id: attrs.pluck(:user_id))
15
16
  end
16
17
 
@@ -27,7 +27,14 @@ module Audiences
27
27
  private
28
28
 
29
29
  def result
30
- @result ||= @scope.where("data LIKE ?", "%#{@query}%")
30
+ @result ||= @scope.where("#{data_attribute_query} LIKE ?", "%#{@query}%")
31
+ end
32
+
33
+ def data_attribute_query
34
+ case @scope.connection.adapter_name
35
+ when "PostgreSQL" then "CAST(data AS TEXT)"
36
+ else "CAST(data AS CHAR)"
37
+ end
31
38
  end
32
39
  end
33
40
  end
data/docs/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Unreleased
2
2
 
3
+ # Version 1.0.3 (2024-05-14)
4
+
5
+ - Fix PostgreSQL compability [#312](https://github.com/powerhome/audiences/pull/312)
6
+ - Fix audiences resources pagination [#313](https://github.com/powerhome/audiences/pull/313)
7
+
3
8
  # Version 1.0.2 (2024-04-30)
4
9
 
5
10
  - Fix mysql2 compability – drop sqlite3 [#292](https://github.com/powerhome/audiences/pull/292)
@@ -31,19 +31,30 @@ module Audiences
31
31
  end
32
32
 
33
33
  def next_page?
34
- start_index = response.fetch("startIndex", 1)
35
- per_page = response["itemsPerPage"].to_i
36
- total_results = response["totalResults"].to_i
37
-
38
34
  start_index + per_page <= total_results
39
35
  end
40
36
 
37
+ def start_index
38
+ response.fetch("startIndex", 1)
39
+ end
40
+
41
+ def per_page
42
+ response["itemsPerPage"].to_i
43
+ end
44
+
45
+ def total_results
46
+ response["totalResults"].to_i
47
+ end
48
+
49
+ def next_index
50
+ start_index + per_page
51
+ end
52
+
41
53
  def next_page
42
54
  return unless next_page?
43
55
 
44
- current_page = @query_options.fetch(:page, 1)
45
56
  ResourcesQuery.new(@client, resource_type: @resource_type, **@query_options,
46
- page: current_page + 1)
57
+ startIndex: next_index)
47
58
  end
48
59
 
49
60
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Audiences
4
- VERSION = "1.0.2"
4
+ VERSION = "1.0.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: audiences
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Palhares
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-30 00:00:00.000000000 Z
11
+ date: 2024-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails