TrestleAdmin / trestle-search

Search plugin for the Trestle admin framework

Home Page:https://trestle.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

search query scope

petitkriket opened this issue · comments

As in the docs, I set a scope like

In Company.rb model

scope :staff_between, ->(from, to) { joins(:job_histories).group('companies.id').having("count(company_id) >= :from AND count(comapny_id) <= :to", from: from, to: to) }

so I can call inside companies_admin.rb
scope :small, -> { Company.staff_between(1, 10) }, label: "1 to 25 collaborators"

But the group() creates an unexpected bahaviour when the results are counted at display
Screenshot_20200502_143929

Is there a way to circumvent that ? the count done to return the badge number gives an hash of results instead

Used Rails Counter Cache feature, working as expected