audiences 1.0.1 → 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: d908257a2da48f7c59f74138a5e92c160682d929826267aad9095f99510f2f3c
4
- data.tar.gz: 313ff13a58a5e64827e4e52cf36b9f214913d9ce0aeb64f23962246552853f87
3
+ metadata.gz: db54cba8b15c751dd4103cb6941fb5dfcbdf3c2094a91a57233f4ee768b06e5c
4
+ data.tar.gz: bef9487c0a68472e81ed365b902ceff656fb6c789c53fe6b36bbcadac5b80d59
5
5
  SHA512:
6
- metadata.gz: 2849064c0ded8cca2a083b3f4aca9d8cbcf1ea6ab10102c96f6de76ffedd23439cbbe2fe2e8743988e5cb97cd375c0ccff69988376361fc5c305e3e75878e250
7
- data.tar.gz: c0af5d5b298135abb4d362f277f2eb7f69855346be5ec262c223c42c71647c33f113b91902b3323191ede6e5787c87a26355b7c1b7387cc154171cd030196b55
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, unique_by: :user_id) # 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,3 +1,18 @@
1
+ # Unreleased
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
+
8
+ # Version 1.0.2 (2024-04-30)
9
+
10
+ - Fix mysql2 compability – drop sqlite3 [#292](https://github.com/powerhome/audiences/pull/292)
11
+
12
+ # Version 1.0.1 (2024-04-25)
13
+
14
+ - Release build adjustments
15
+
1
16
  # Version 1.0 (2024-04-25)
2
17
 
3
- * Inaugural release of Audiences
18
+ - Inaugural release of Audiences
@@ -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.1"
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.1
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-25 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