Is there a way to bypass counting on index view...
# avo-2
m
Thread automatically created by ritec in #740893011994738751
l
there isn't a built in way of configuring that at the moment
not sure if Avo does that or it's something coming from the pagination
pagy
is used for pagination in Avo
g
ok thanks, I know kaminari has a way to override that behavior, will look into pagy.
l
ok
another thing you could try is to override the
resource_table_component
(both .rb and .erb) files inside your app and remove the bit that says
pagy.count
https://github.com/avo-hq/avo/blob/main/app/components/avo/index/resource_table_component.rb https://github.com/avo-hq/avo/blob/main/app/components/avo/index/resource_table_component.erb
you could test and see if that's causign you trouble
l
I just made something similar: Overrided the paginator component https://github.com/avo-hq/avo/blob/main/app/components/avo/paginator_component.html.erb L36 from
<% if @pagy.count > 0 %>
to
<% if !index_params.dig(:pagy_count_off) && @pagy.count > 0 %>
Now whenever i want to disable some resource pagination i go to that resource's controller and implement this method
Copy code
ruby
  def set_index_params
    super
    @index_params.merge! pagy_count_off: true
  end
This would work joined to the @lemon-wall-20836 sugestion of overriding the
resource_table_component
g
Possibly dumb question but where would the view ber overriden, what file path in my app? Tried a couple thigns and not picking up.
Also see https://github.com/ddnexus/pagy/blob/master/docs/extras/countless.md#set-up-countless_minimal-mode Maybe something like this would be better:
Copy code
before_action :set_pagy, only: :index

  def set_pagy
    @pagy, @records = pagy_countless(User.all, countless_minimal: true)
  end
Tried creating the overriden file under: app/components/avo/paginator_component.html.erb but it is not being picked up.
l
Hey, it should work, I extracred the
.rb
too when tried it
Just confirmed, the
.rb
is actually required too in order to override the component
this can be a usefull feature for big tables, would be great to have an issue to track it down
g
I am not sure, this is doing anything regarding the Resource count? PAgy is still counting here in the Base Controller:
Copy code
@pagy, @models = pagy(@query, items: @index_params[:per_page], link_extra: "data-turbo-frame=\"#{params[:turbo_frame]}\"", size: [1, 2, 2, 1], params: extra_pagy_params)
l
@loud-jewelry-99127 this seems like a problem that many might have
Maybe we can change that pagination to be pageless
I think that pattern solves the counting issue
And we can make it configurable
let's create a ticket and prioritize it
l
@lemon-wall-20836 i came across this issue, i think its related https://github.com/avo-hq/avo/issues/1748
l
can we make that an option in Avo?
l
I think that's the best approach, configurable option
l
ok. let's do it please. Avo 2 and 3