Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mail.find(keys: "ALL", order: :desc, count: 20, what: :first) doesn't return the most 20 recent messages. #1610

Open
wflanagan opened this issue Apr 19, 2024 · 1 comment

Comments

@wflanagan
Copy link

wflanagan commented Apr 19, 2024

When I do this query:

Mail.Find(keys: "ALL", order: :desc, count: 20, what: :first)

it's logical to me that it would return the 20 most recent items. But, it doesn't. It returns the 20 oldest.

To get the 20 most recent, and to thus implement some sort of hacky pagination, I have to do:

Mail.find(keys: "ALL", order: :asc, count: 20, what: :last) 

and then reverse the results to get the most recent items.

I'm not sure if i'm doing something wrong, but i spent a couple hours on this and didn't find a good solution.

Please close if this is "as designed." But, to me, it seems the order is applied AFTER the what is applied. The what is actually the ordering, and the order is what's done after the selection based on the count and what.

@wflanagan wflanagan changed the title Mail.find(keys: "ALL", order: :desc, count: 20, what: :first) doesn't return the most 20 recent items. Mail.find(keys: "ALL", order: :desc, count: 20, what: :first) doesn't return the most 20 recent messages. Apr 19, 2024
@sebbASF
Copy link
Collaborator

sebbASF commented Apr 19, 2024

Have you tried: Mail.find(keys: "ALL", order: :desc, count: 20, what: :last) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants