action_tracker_client 0.1.3 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b49e126178e1c41aeac5bca208cf545dfd9d221cee9ff843506b889ec56620cc
4
- data.tar.gz: a572ecb730e7fafc315d31905b0ad8a5fbfb1c1d178f1ebe924050cce8657104
3
+ metadata.gz: 96e3a4be249df05d4ee1422b65d7812b559657b0a4d0f8faa8b64b3b31cf68b4
4
+ data.tar.gz: abb42792b81c98b9c56553f564dd1f3f08a3787763b4a9a2eb456601891430cb
5
5
  SHA512:
6
- metadata.gz: baf06c442cf8bc2a726af177be71084618d364173282869fdebf20e8dbd0a0679f9aa163639f038f43bc1e10f595ce367765a05b2629643ac68f644035dd438c
7
- data.tar.gz: 6b94ce8fa2ce2904841d8429eb273f78e901ad7cb33871d7f1b0885c6e392aed5ca0f407daa135b6f2b49e1caa48390ee03b78e35ea3040bee5e06cac0cf5b11
6
+ metadata.gz: e8fe4c30e5c17ede01292ce6e206089cb4f5005284f0b8d34e99bfd04f0d0271669c94666716d522131d62b1985f37f0bf8693129201904e53b22c1433f4f265
7
+ data.tar.gz: d9e1369bbeaca0b385bf275bd963a4924fc91517ec845d38136394fec67dc064fdd143686fdffb11e39f68c1860af07900d40076d7944f3f06857de8e5e2dd6f
data/.rubocop.yml CHANGED
@@ -45,11 +45,3 @@ Metrics/BlockLength:
45
45
  Max: 50
46
46
  Exclude:
47
47
  - "**/*_spec.rb"
48
-
49
- ##################### Rails ##################################
50
-
51
- Rails:
52
- Enabled: true
53
-
54
- Rails/SkipsModelValidations:
55
- Enabled: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- action_tracker_client (0.1.1)
4
+ action_tracker_client (0.1.3)
5
5
  activemodel (>= 4.0)
6
6
  activesupport (>= 4.0)
7
7
  api_signature (~> 0.1.5)
@@ -12,13 +12,14 @@ PATH
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- activemodel (5.2.3)
16
- activesupport (= 5.2.3)
17
- activesupport (5.2.3)
15
+ activemodel (6.0.1)
16
+ activesupport (= 6.0.1)
17
+ activesupport (6.0.1)
18
18
  concurrent-ruby (~> 1.0, >= 1.0.2)
19
19
  i18n (>= 0.7, < 2)
20
20
  minitest (~> 5.1)
21
21
  tzinfo (~> 1.1)
22
+ zeitwerk (~> 2.2)
22
23
  addressable (2.6.0)
23
24
  public_suffix (>= 2.0.2, < 4.0)
24
25
  api_signature (0.1.5)
@@ -56,10 +57,10 @@ GEM
56
57
  guard-compat (~> 1.1)
57
58
  rspec (>= 2.99.0, < 4.0)
58
59
  hashdiff (0.3.9)
59
- httparty (0.17.0)
60
+ httparty (0.17.1)
60
61
  mime-types (~> 3.0)
61
62
  multi_xml (>= 0.5.2)
62
- i18n (1.6.0)
63
+ i18n (1.7.0)
63
64
  concurrent-ruby (~> 1.0)
64
65
  ice_nine (0.11.2)
65
66
  listen (3.1.5)
@@ -68,10 +69,10 @@ GEM
68
69
  ruby_dep (~> 1.2)
69
70
  lumberjack (1.0.13)
70
71
  method_source (0.9.2)
71
- mime-types (3.2.2)
72
+ mime-types (3.3)
72
73
  mime-types-data (~> 3.2015)
73
- mime-types-data (3.2019.0331)
74
- minitest (5.11.3)
74
+ mime-types-data (3.2019.1009)
75
+ minitest (5.13.0)
75
76
  model_auditor (0.0.2)
76
77
  multi_xml (0.6.0)
77
78
  nenv (0.3.0)
@@ -119,6 +120,7 @@ GEM
119
120
  addressable (>= 2.3.6)
120
121
  crack (>= 0.3.2)
121
122
  hashdiff
123
+ zeitwerk (2.2.1)
122
124
 
123
125
  PLATFORMS
124
126
  ruby
@@ -133,4 +135,4 @@ DEPENDENCIES
133
135
  webmock (~> 3.5, >= 3.5.1)
134
136
 
135
137
  BUNDLED WITH
136
- 1.16.2
138
+ 1.17.3
@@ -8,18 +8,19 @@ require 'active_support/core_ext/object'
8
8
 
9
9
  module ActionTracker
10
10
  autoload :Config, 'action_tracker/config'
11
+ autoload :Recorder, 'action_tracker/recorder'
11
12
 
12
13
  autoload :CollectionProxy, 'action_tracker/utils/collection_proxy'
13
14
  autoload :Connection, 'action_tracker/utils/connection'
14
15
  autoload :Pagination, 'action_tracker/utils/pagination'
15
16
  autoload :RecordsCollection, 'action_tracker/utils/records_collection'
16
17
  autoload :SignedRequest, 'action_tracker/utils/signed_request'
17
-
18
- autoload :Recorder, 'action_tracker/recorder'
18
+ autoload :HttpGateway, 'action_tracker/utils/http_gateway'
19
19
 
20
20
  module Models
21
21
  autoload :ApplicationRecord, 'action_tracker/models/application_record'
22
22
  autoload :TransitionRecord, 'action_tracker/models/transition_record'
23
+ autoload :StatisticRecord, 'action_tracker/models/statistic_record'
23
24
  autoload :Payload, 'action_tracker/models/payload'
24
25
  autoload :User, 'action_tracker/models/user'
25
26
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal :true
2
+
3
+ module ActionTracker
4
+ module Models
5
+ class StatisticRecord < ActionTracker::Models::ApplicationRecord
6
+ include ActionTracker::HttpGateway
7
+
8
+ attribute :user_id, Integer
9
+ attribute :report_date, String
10
+ attribute :total_count, Integer
11
+ attribute :targets, Hash
12
+
13
+ def count(params = {})
14
+ request processed_path(collection_path, params)
15
+ end
16
+
17
+ def daily(params = {})
18
+ path = processed_path("#{collection_path}/daily", params)
19
+ parse_response request(path)
20
+ end
21
+
22
+ def collection_path
23
+ 'statistics'
24
+ end
25
+ end
26
+ end
27
+ end
@@ -3,6 +3,8 @@
3
3
  module ActionTracker
4
4
  module Models
5
5
  class TransitionRecord < ActionTracker::Models::ApplicationRecord
6
+ include ActionTracker::HttpGateway
7
+
6
8
  mimic 'transition'
7
9
 
8
10
  attribute :target_id, Integer
@@ -31,29 +33,19 @@ module ActionTracker
31
33
  end
32
34
 
33
35
  def index(params = {})
34
- @path = processed_path(collection_path, params)
35
-
36
- parse_response
36
+ parse_response request(processed_path(collection_path, params))
37
37
  end
38
38
 
39
39
  def filtered_by_users(params = {})
40
- @path = processed_path(users(params[:user_id]), params.except(:user_id))
40
+ path = processed_path(users(params[:user_id]), params.except(:user_id))
41
41
 
42
- parse_response
42
+ parse_response request(path)
43
43
  end
44
44
 
45
45
  def filtered_by_users_count(params = {})
46
- @path = processed_path(users(params[:user_id]) + '/count', params.except(:user_id))
47
-
48
- response
49
- end
50
-
51
- def collection_path
52
- 'transitions'
53
- end
46
+ path = processed_path(users(params[:user_id]) + '/count', params.except(:user_id))
54
47
 
55
- def users(user_id)
56
- "users/#{user_id}"
48
+ request(path)
57
49
  end
58
50
 
59
51
  def payload
@@ -68,25 +60,21 @@ module ActionTracker
68
60
  [event, content].reject(&:blank?).compact.join(': ')
69
61
  end
70
62
 
71
- private
72
-
73
- def parse_response
74
- ActionTracker::CollectionProxy.new response, self.class.model_name
63
+ def collection_path
64
+ 'transitions'
75
65
  end
76
66
 
77
- def response
78
- @response ||= Connection.new.get(@path)
67
+ def users(user_id)
68
+ "users/#{user_id}"
79
69
  end
80
70
 
71
+ private
72
+
81
73
  def check_payload
82
74
  return if payload.valid?
83
75
 
84
76
  errors.add(:payload, :invalid)
85
77
  end
86
-
87
- def processed_path(collection_name, params)
88
- [collection_name, params.to_query].reject(&:blank?).compact.join('?')
89
- end
90
78
  end
91
79
  end
92
80
  end
@@ -23,7 +23,7 @@ module ActionTracker
23
23
  end
24
24
 
25
25
  def raw_data
26
- @response.dig(model_name.plural)
26
+ @response.dig(model_name.plural) || @response.dig('data')
27
27
  end
28
28
 
29
29
  def entry_name(options = {})
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionTracker
4
+ module HttpGateway
5
+ protected
6
+
7
+ def request(path)
8
+ Connection.new.get(path)
9
+ end
10
+
11
+ def response
12
+ @response ||= Connection.new.get(@path)
13
+ end
14
+
15
+ def processed_path(collection_name, params)
16
+ [collection_name, params.to_query].reject(&:blank?).compact.join('?')
17
+ end
18
+
19
+ def parse_response(response)
20
+ ActionTracker::CollectionProxy.new response, self.class.model_name
21
+ end
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module ActionTracker
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_tracker_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Malinovskiy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-29 00:00:00.000000000 Z
11
+ date: 2019-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -221,6 +221,7 @@ files:
221
221
  - lib/action_tracker/config.rb
222
222
  - lib/action_tracker/models/application_record.rb
223
223
  - lib/action_tracker/models/payload.rb
224
+ - lib/action_tracker/models/statistic_record.rb
224
225
  - lib/action_tracker/models/transition_record.rb
225
226
  - lib/action_tracker/models/user.rb
226
227
  - lib/action_tracker/recorder.rb
@@ -230,6 +231,7 @@ files:
230
231
  - lib/action_tracker/templates/update.rb
231
232
  - lib/action_tracker/utils/collection_proxy.rb
232
233
  - lib/action_tracker/utils/connection.rb
234
+ - lib/action_tracker/utils/http_gateway.rb
233
235
  - lib/action_tracker/utils/pagination.rb
234
236
  - lib/action_tracker/utils/records_collection.rb
235
237
  - lib/action_tracker/utils/signed_request.rb