forest_liana 8.2.0 → 8.3.1

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: aada07cfc20b60dc59e85b49de4b7d719a2f6d8fddcc7a432b36fbfb754a310e
4
- data.tar.gz: bad11ea920e7c0a191f201ad7ba77cb23b54e5a1861b7e2d2d464d23f7885032
3
+ metadata.gz: f575399255a09d606c838be6a483b043c8b517eca0a8ccca55c747334555616b
4
+ data.tar.gz: fbe167b9daa4f6b3d22ddfd58e297cd3da3e020c165a548e37d8ae886c3671ed
5
5
  SHA512:
6
- metadata.gz: d8a2918ef6b5271a11c26e1fb84f6eec5a202eee345ab34412e8669de17fa75ca0a1edeb150cb259e154ea00ffed7e46e552bab7008b5a3bba9dd90b1358287f
7
- data.tar.gz: 4fc0f3ea03ef0a04d63fa2ce633769b939b67892988becb3884e8109dfbbff0ef8fd6a8ff1dbc185a58d91ab61c85cb30b06cf0e96e18cbfb69131f7da1c0699
6
+ metadata.gz: 025fdca59a9d40cc79221d021f9f64b08aa95ad7cbb7035ee6f1adcc0350c00c7427cd80a25ddaebfe334c48ff83e92a30156709e1ac5a6e3701509b29bae5b9
7
+ data.tar.gz: 189a32d33adc6f1d898d10328032ae2a3a36da7dfd5be070bd555afba75869b6069ae306bee9d6b9215e55efb7354c11a42092c80811c7c0659fa5e2c021d161
@@ -97,7 +97,7 @@ module ForestLiana
97
97
  Rails.cache.fetch('forest.stats', expires_in: TTL) do
98
98
  stat_hash = []
99
99
  get_permissions('/liana/v4/permissions/renderings/' + rendering_id)['stats'].each do |stat|
100
- stat_hash << "#{stat['type']}:#{Digest::SHA1.hexdigest(stat.sort.to_h.to_s)}"
100
+ stat_hash << "#{stat['type']}:#{Digest::SHA1.hexdigest(stat.deep_sort.to_s)}"
101
101
  end
102
102
 
103
103
  stat_hash
@@ -160,12 +160,9 @@ module ForestLiana
160
160
  end
161
161
 
162
162
  def sort_query
163
- column = nil
164
- order = 'DESC'
165
-
166
163
  if @params[:sort]
167
164
  @params[:sort].split(',').each do |field|
168
- order_detected = detect_sort_order(@params[:sort])
165
+ order_detected = detect_sort_order(field)
169
166
  order = order_detected.upcase
170
167
  field.slice!(0) if order_detected == :desc
171
168
 
@@ -175,14 +172,12 @@ module ForestLiana
175
172
  else
176
173
  column = field
177
174
  end
175
+
176
+ @records = @records.order(Arel.sql("#{column} #{order}"))
178
177
  end
179
178
  end
180
179
 
181
- if column
182
- @records = @records.order(Arel.sql("#{column} #{order}"))
183
- else
184
- @records
185
- end
180
+ @records
186
181
  end
187
182
 
188
183
  def detect_reference(param)
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "8.2.0"
2
+ VERSION = "8.3.1"
3
3
  end
@@ -2,24 +2,8 @@ require 'rails_helper'
2
2
  require 'json'
3
3
 
4
4
  describe "Stats", type: :request do
5
-
6
- token = JWT.encode({
7
- id: 1,
8
- email: 'michael.kelso@that70.show',
9
- first_name: 'Michael',
10
- last_name: 'Kelso',
11
- team: 'Operations',
12
- rendering_id: '1',
13
- exp: Time.now.to_i + 2.weeks.to_i,
14
- permission_level: 'admin'
15
- }, ForestLiana.auth_secret, 'HS256')
16
-
17
- headers = {
18
- 'Accept' => 'application/json',
19
- 'Content-Type' => 'application/json',
20
- 'Authorization' => "Bearer #{token}"
21
- }
22
-
5
+ let(:rendering_id) { '13' }
6
+ let(:scopes) { {'scopes' => {}, 'team' => {'id' => '1', 'name' => 'Operations'}} }
23
7
  let(:schema) {
24
8
  [
25
9
  ForestLiana::Model::Collection.new({
@@ -30,10 +14,31 @@ describe "Stats", type: :request do
30
14
  ]
31
15
  }
32
16
 
17
+ let(:token) {
18
+ JWT.encode({
19
+ id: 1,
20
+ email: 'michael.kelso@that70.show',
21
+ first_name: 'Michael',
22
+ last_name: 'Kelso',
23
+ team: 'Operations',
24
+ rendering_id: rendering_id,
25
+ exp: Time.now.to_i + 2.weeks.to_i,
26
+ permission_level: 'user'
27
+ }, ForestLiana.auth_secret, 'HS256')
28
+ }
29
+
30
+ let(:headers) {
31
+ {
32
+ 'Accept' => 'application/json',
33
+ 'Content-Type' => 'application/json',
34
+ 'Authorization' => "Bearer #{token}"
35
+ }
36
+ }
37
+
33
38
  before do
34
39
  Rails.cache.write('forest.users', {'1' => { 'id' => 1, 'roleId' => 1, 'rendering_id' => '1' }})
35
40
  Rails.cache.write('forest.has_permission', true)
36
- allow_any_instance_of(ForestLiana::Ability::Fetch)
41
+ allow_any_instance_of(ForestLiana::Ability::Permission)
37
42
  .to receive(:get_permissions)
38
43
  .and_return(
39
44
  {
@@ -45,6 +50,31 @@ describe "Stats", type: :request do
45
50
  "aggregateFieldName" => nil,
46
51
  "sourceCollectionName" => "Owner"
47
52
  },
53
+ {
54
+ "type" => "Objective",
55
+ "sourceCollectionName" => "Owner",
56
+ "aggregateFieldName" => nil,
57
+ "aggregator" => "Count",
58
+ "objective" => 200,
59
+ "filter" => nil,
60
+ },
61
+ {
62
+ "type" => "Pie",
63
+ "sourceCollectionName" => "Owner",
64
+ "aggregateFieldName" => nil,
65
+ "groupByFieldName" => "id",
66
+ "aggregator" => "Count",
67
+ "filter" => nil,
68
+ },
69
+ {
70
+ "type" => "Line",
71
+ "sourceCollectionName" => "Owner",
72
+ "aggregateFieldName" => nil,
73
+ "groupByFieldName" => "hired_at",
74
+ "aggregator" => "Count",
75
+ "timeRange" => "Week",
76
+ "filter" => nil,
77
+ },
48
78
  {
49
79
  "type" => "Value",
50
80
  "query" => "SELECT COUNT(*) AS value FROM products;"
@@ -53,13 +83,9 @@ describe "Stats", type: :request do
53
83
  }
54
84
  )
55
85
 
56
- ForestLiana::ScopeManager.class_variable_set(:@@scopes_cache, {
57
- '1' => {
58
- :fetched_at => Time.now,
59
- :scopes => {}
60
- }
61
- })
62
-
86
+ ForestLiana::ScopeManager.invalidate_scope_cache(rendering_id)
87
+ allow(ForestLiana::ScopeManager).to receive(:fetch_scopes).and_return(scopes)
88
+
63
89
  allow(ForestLiana).to receive(:apimap).and_return(schema)
64
90
  allow(ForestLiana::IpWhitelist).to receive(:retrieve) { true }
65
91
  allow(ForestLiana::IpWhitelist).to receive(:is_ip_whitelist_retrieved) { true }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_liana
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.2.0
4
+ version: 8.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Munda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-29 00:00:00.000000000 Z
11
+ date: 2024-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails