Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
297 changes: 297 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,297 @@
PATH
remote: .
specs:
forest_liana (9.15.8)
bcrypt
deepsort
forestadmin-jsonapi-serializers (>= 0.14.0)
groupdate (>= 5.0.0)
httparty
ipaddress
json
json-jwt (>= 1.16.0)
jwt
openid_connect (= 1.4.2)
rack-cors
rails (>= 6.1.7.9)
useragent

GEM
remote: https://rubygems.org/
specs:
actioncable (6.1.7.9)
actionpack (= 6.1.7.9)
activesupport (= 6.1.7.9)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.1.7.9)
actionpack (= 6.1.7.9)
activejob (= 6.1.7.9)
activerecord (= 6.1.7.9)
activestorage (= 6.1.7.9)
activesupport (= 6.1.7.9)
mail (>= 2.7.1)
actionmailer (6.1.7.9)
actionpack (= 6.1.7.9)
actionview (= 6.1.7.9)
activejob (= 6.1.7.9)
activesupport (= 6.1.7.9)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.1.7.9)
actionview (= 6.1.7.9)
activesupport (= 6.1.7.9)
rack (~> 2.0, >= 2.0.9)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.1.7.9)
actionpack (= 6.1.7.9)
activerecord (= 6.1.7.9)
activestorage (= 6.1.7.9)
activesupport (= 6.1.7.9)
nokogiri (>= 1.8.5)
actionview (6.1.7.9)
activesupport (= 6.1.7.9)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.1.7.9)
activesupport (= 6.1.7.9)
globalid (>= 0.3.6)
activemodel (6.1.7.9)
activesupport (= 6.1.7.9)
activerecord (6.1.7.9)
activemodel (= 6.1.7.9)
activesupport (= 6.1.7.9)
activestorage (6.1.7.9)
actionpack (= 6.1.7.9)
activejob (= 6.1.7.9)
activerecord (= 6.1.7.9)
activesupport (= 6.1.7.9)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (6.1.7.9)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
aes_key_wrap (1.1.0)
attr_required (1.0.2)
base64 (0.3.0)
bcrypt (3.1.20)
bigdecimal (3.3.1)
bindata (2.5.1)
builder (3.3.0)
byebug (12.0.0)
concurrent-ruby (1.3.4)
crass (1.0.6)
date (3.4.1)
deepsort (0.5.0)
diff-lcs (1.6.2)
docile (1.4.1)
erubi (1.13.1)
faraday (2.14.0)
faraday-net_http (>= 2.0, < 3.5)
json
logger
faraday-follow_redirects (0.4.0)
faraday (>= 1, < 3)
faraday-net_http (3.4.1)
net-http (>= 0.5.0)
forestadmin-jsonapi-serializers (2.0.0.pre.beta.2)
activesupport
globalid (1.3.0)
activesupport (>= 6.1)
groupdate (5.2.2)
activesupport (>= 5)
httparty (0.21.0)
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
httpclient (2.9.0)
mutex_m
i18n (1.14.7)
concurrent-ruby (~> 1.0)
ipaddress (0.8.3)
json (2.15.1)
json-jwt (1.17.0)
activesupport (>= 4.2)
aes_key_wrap
base64
bindata
faraday (~> 2.0)
faraday-follow_redirects
jwt (3.1.2)
base64
logger (1.7.0)
loofah (2.24.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
marcel (1.1.0)
method_source (1.1.0)
mini_mime (1.1.5)
minitest (5.26.0)
multi_xml (0.7.2)
bigdecimal (~> 3.1)
mutex_m (0.3.0)
net-http (0.6.0)
uri
net-imap (0.5.12)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.5.1)
net-protocol
nio4r (2.7.4)
nokogiri (1.18.10-arm64-darwin)
racc (~> 1.4)
openid_connect (1.4.2)
activemodel
attr_required (>= 1.0.0)
json-jwt (>= 1.15.0)
net-smtp
rack-oauth2 (~> 1.21)
swd (~> 1.3)
tzinfo
validate_email
validate_url
webfinger (~> 1.2)
public_suffix (6.0.2)
racc (1.8.1)
rack (2.2.20)
rack-cors (2.0.2)
rack (>= 2.0.0)
rack-oauth2 (1.21.3)
activesupport
attr_required
httpclient
json-jwt (>= 1.11.0)
rack (>= 2.1.0)
rack-test (2.2.0)
rack (>= 1.3)
rails (6.1.7.9)
actioncable (= 6.1.7.9)
actionmailbox (= 6.1.7.9)
actionmailer (= 6.1.7.9)
actionpack (= 6.1.7.9)
actiontext (= 6.1.7.9)
actionview (= 6.1.7.9)
activejob (= 6.1.7.9)
activemodel (= 6.1.7.9)
activerecord (= 6.1.7.9)
activestorage (= 6.1.7.9)
activesupport (= 6.1.7.9)
bundler (>= 1.15.0)
railties (= 6.1.7.9)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.3.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.6.2)
loofah (~> 2.21)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
railties (6.1.7.9)
actionpack (= 6.1.7.9)
activesupport (= 6.1.7.9)
method_source
rake (>= 12.2)
thor (~> 1.0)
rake (13.3.0)
rspec-core (3.13.5)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-rails (6.1.5)
actionpack (>= 6.1)
activesupport (>= 6.1)
railties (>= 6.1)
rspec-core (~> 3.13)
rspec-expectations (~> 3.13)
rspec-mocks (~> 3.13)
rspec-support (~> 3.13)
rspec-support (3.13.4)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.13.2)
simplecov_json_formatter (0.1.4)
sprockets (4.2.2)
concurrent-ruby (~> 1.0)
logger
rack (>= 2.2.4, < 4)
sprockets-rails (3.5.2)
actionpack (>= 6.1)
activesupport (>= 6.1)
sprockets (>= 3.0.0)
sqlite3 (1.7.3-arm64-darwin)
swd (1.3.0)
activesupport (>= 3)
attr_required (>= 0.0.5)
httpclient (>= 2.4)
thor (1.4.0)
timecop (0.9.10)
timeout (0.4.3)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
uri (1.0.4)
useragent (0.16.11)
validate_email (0.1.6)
activemodel (>= 3.0)
mail (>= 2.2.5)
validate_url (1.0.15)
activemodel (>= 3.0.0)
public_suffix
webfinger (1.2.0)
activesupport
httpclient (>= 2.4)
websocket-driver (0.8.0)
base64
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.7.3)

PLATFORMS
arm64-darwin-23

DEPENDENCIES
bcrypt
byebug
concurrent-ruby (= 1.3.4)
deepsort
forest_liana!
forestadmin-jsonapi-serializers
groupdate (= 5.2.2)
httparty (= 0.21.0)
ipaddress (= 0.8.3)
json
json-jwt (>= 1.16)
jwt
openid_connect (= 1.4.2)
rack-cors
rails (= 6.1.7.9)
rake
rspec-rails
simplecov (~> 0.22)
simplecov_json_formatter (~> 0.1.4)
sqlite3 (~> 1.4)
timecop
useragent

BUNDLED WITH
2.7.2
4 changes: 3 additions & 1 deletion app/controllers/forest_liana/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def fields_per_model(params_fields, model)
fields[relation_name] = relation_fields
elsif model.reflect_on_association(relation_name.to_sym)
model_association = model.reflect_on_association(relation_name.to_sym)
if model_association
if model_association && !model_association.polymorphic?
model_name = ForestLiana.name_for(model_association.klass)
# NOTICE: Join fields in case of model with self-references.
if fields[model_name]
Expand All @@ -184,6 +184,8 @@ def fields_per_model(params_fields, model)
else
fields[model_name] = relation_fields
end
elsif model_association && model_association.polymorphic?
fields[relation_name] = relation_fields
end
else
smart_relations.each do |smart_relation|
Expand Down
27 changes: 25 additions & 2 deletions app/services/forest_liana/has_many_getter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,29 @@ def perform
end

def count
@records_count = @records.count
association_class = model_association

if association_class.primary_key.is_a?(Array)
adapter_name = association_class.connection.adapter_name.downcase

if adapter_name.include?('sqlite')
# For SQLite: concatenate columns for DISTINCT count
pk_concat = association_class.primary_key.map do |pk|
"#{association_class.table_name}.#{pk}"
end.join(" || '|' || ")

@records_count = @records.distinct.count(Arel.sql(pk_concat))
else
# For PostgreSQL/MySQL: use DISTINCT with multiple columns
pk_columns = association_class.primary_key.map do |pk|
"#{association_class.table_name}.#{pk}"
end.join(', ')

@records_count = @records.distinct.count(Arel.sql(pk_columns))
end
else
@records_count = @records.count
end
end

def query_for_batch
Expand Down Expand Up @@ -72,7 +94,8 @@ def model_association
end

def prepare_query
association = get_resource().find(@params[:id]).send(@params[:association_name])
parent_record = ForestLiana::Utils::CompositePrimaryKeyHelper.find_record(get_resource(), @resource, @params[:id])
association = parent_record.send(@params[:association_name])
@records = optimize_record_loading(association, @search_query_builder.perform(association))
end

Expand Down
2 changes: 1 addition & 1 deletion app/services/forest_liana/resource_getter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def initialize(resource, params, forest_user)
def perform
records = optimize_record_loading(@resource, get_resource())
scoped_records = ForestLiana::ScopeManager.apply_scopes_on_records(records, @user, @collection_name, @params[:timezone])
@record = scoped_records.find(@params[:id])
@record = ForestLiana::Utils::CompositePrimaryKeyHelper.find_record(scoped_records, @resource, @params[:id])
end
end
end
Loading
Loading