aesmail / aesmail/kaffy

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

Open
#278 1 comment 0 reactions 1 assignee Claimed by @aesmail View on GitHub
enhancement
Dominant language
Elixir
Stars
1.4k
Forks
171
PR merge metrics
No merged PRs in 30d

Description

**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](https://github.com/aesmail/kaffy/blob/fc54f1c7b0ef6555d4aad3d352c0dd8cd00a8051/lib/kaffy/resource_query.ex#L29) 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
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.