aesmail / kaffy

Powerfully simple admin package for phoenix applications
https://kaffy.fly.dev/admin/
MIT License
1.3k stars 153 forks source link

[FEATURE-REQUEST] custom_index_query should receive all rather than paged #278

Open juantascon opened 12 months ago

juantascon commented 12 months ago

Describe the problem you're proposing to solve

Use of custom_index_query is very limited since it only works on the currently paged view. When you have a custom index query that returns fewer items this issue leads to invalid total numbers and invalid page counts.

Describe the solution you'd like

custom_index_query should be used to limit the whole query rather than just the currently paged query, i.e here we should pass all rather than paged, then build the filtered query from there on.

Describe alternatives you've considered

Perhaps add a new custom_query instead?

Additional context

This type of query breaks records counting and pagination (it shows more pages than there are) work:

def custom_index_query(_conn, _schema, query) do
    from(r in query, distinct: r.my_custom_field)
end
juantascon commented 12 months ago

@aesmail I can provide a pullrq if you point me to what solution you prefer.