forest_liana 1.5.19 → 1.5.20

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
  SHA1:
3
- metadata.gz: d79d5b975e9e3892289dbff875172e1146adc7bf
4
- data.tar.gz: 6cc20037481515764004884a3f0aee305516e4af
3
+ metadata.gz: c0609cf8516ae79379606bff03060b124cb88329
4
+ data.tar.gz: e46eb8f4d03d79cd6b7ac90b731c010e337180ab
5
5
  SHA512:
6
- metadata.gz: 17f1f4babee8484e60c2198d7133e5ddc3c8069fd9386ea27330cb5bfee53e1d12e56fd80eb8dd405fbc6ec4cbc69d9d267535942f949d15b5d3c08125e2c78e
7
- data.tar.gz: 00486b9e196a49763937c84835d28b1e25f9085eb7253e418efd5e731922f2024bc14de655f871570d180aeba682c02d59d402783e2d16be68d47285a7eb9f68
6
+ metadata.gz: 9a7c1cee91ef4161f980b81ba71cd2ea0569f41ea6ecf1b8058d437718fba656607ad15efff5e8e3f410bdc5e33467c40638dd45e945215f76053aed3157cc02
7
+ data.tar.gz: 21941decf71abafbaa33ef7faa7bd6a265be8d8d40dfd3fa4562214a57aff1e0f26c5b63e9eac2d6ecae89e24b3e5b47fb4a5f570bea2dc98bda4366a6a56319
@@ -1,5 +1,5 @@
1
1
  module ForestLiana
2
- class ApimapsController < ActionController::Base
2
+ class ApimapsController < ::ActionController::Base
3
3
  def index
4
4
  head :no_content
5
5
  end
@@ -1,7 +1,7 @@
1
1
  require 'jwt'
2
2
 
3
3
  module ForestLiana
4
- class ApplicationController < ActionController::Base
4
+ class ApplicationController < ::ActionController::Base
5
5
  if Rails::VERSION::MAJOR < 4
6
6
  before_filter :authenticate_user_from_jwt
7
7
  else
@@ -1,5 +1,5 @@
1
1
  module ForestLiana
2
- class SessionsController < ActionController::Base
2
+ class SessionsController < ::ActionController::Base
3
3
 
4
4
  def create
5
5
  @error_message = nil
@@ -96,7 +96,11 @@ module ForestLiana
96
96
 
97
97
  @params['data']['attributes'].each do |key, value|
98
98
  if value && carrierwave_attribute?(key)
99
- @attributes[key] = ForestLiana::Base64StringIO.new(value)
99
+ if value.match(/\Adata:\w+\/.+;base64,.+/)
100
+ @attributes[key] = ForestLiana::Base64StringIO.new(value)
101
+ else
102
+ @attributes.delete(key)
103
+ end
100
104
  end
101
105
  end
102
106
  end
@@ -3,6 +3,7 @@ module ForestLiana
3
3
  def initialize(resource, params)
4
4
  @resource = resource
5
5
  @params = params
6
+ @count_needs_includes = false
6
7
  @field_names_requested = field_names_requested
7
8
 
8
9
  get_segment()
@@ -17,18 +18,25 @@ module ForestLiana
17
18
  @records = @records.where(@segment.where.call())
18
19
  end
19
20
 
20
- @records = @records.eager_load(includes)
21
-
22
21
  @records = search_query
23
- @sorted_records = sort_query
22
+ @records_to_count = @records
23
+
24
+ # NOTICE: For performance reasons, do not eager load the data if there is
25
+ # no search or filters on associations.
26
+ if @count_needs_includes
27
+ @records_to_count = @records_to_count.eager_load(includes)
28
+ end
29
+
30
+ @records = @records.eager_load(includes)
31
+ @records_sorted = sort_query
24
32
  end
25
33
 
26
34
  def records
27
- @sorted_records.offset(offset).limit(limit).to_a
35
+ @records_sorted.offset(offset).limit(limit).to_a
28
36
  end
29
37
 
30
38
  def count
31
- @records.count
39
+ @records_to_count.count
32
40
  end
33
41
 
34
42
  def includes
@@ -67,10 +75,13 @@ module ForestLiana
67
75
  @params[:filter].each do |field, values|
68
76
  if field.include? ':'
69
77
  associations_for_query << field.split(':').first.to_sym
78
+ @count_needs_includes = true
70
79
  end
71
80
  end
72
81
  end
73
82
 
83
+ @count_needs_includes = true if @params[:search]
84
+
74
85
  if @params[:sort] && @params[:sort].include?('.')
75
86
  associations_for_query << @params[:sort].split('.').first.to_sym
76
87
  end
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "1.5.19"
2
+ VERSION = "1.5.20"
3
3
  end
@@ -1,4 +1,4 @@
1
- class ApplicationController < ActionController::Base
1
+ class ApplicationController < ::ActionController::Base
2
2
  # Prevent CSRF attacks by raising an exception.
3
3
  # For APIs, you may want to use :null_session instead.
4
4
  protect_from_forgery with: :exception
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_liana
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.19
4
+ version: 1.5.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Munda