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

running get_events from aw_client returns events in reverse order #382

Open
skewballfox opened this issue May 4, 2023 · 1 comment
Open

Comments

@skewballfox
Copy link
Contributor

not sure if this is a bug in aw_client or the server, or if this is just an undocumented but desired feature.

if you call client.get_events(<bucket_id>,start=ealier_timestamp, end=later_timestamp) and aw_server_rust is running, the list is returned in reverse order: from latest to earliest event. example:

from aw_client.client import ActivityWatchClient
import socket
hostname=socket.gethostname()
afk_events=client.get_events(f"aw-watcher-afk_{hostname}")
print(afk_events[:5:]

this pattern holds for any given bucket.

If this is intended behavior, I think this should be mentioned in the documentation for the function.

Also, if this is a bug in the python client, let me know and I'll create an issue there, but I don't think it is, as looking at the source it's passing the params as intended and returning the results

@ErikBjare
Copy link
Member

ErikBjare commented Jun 17, 2023

I think this is the intended sort order, as both aw-server-rust and aw-server-python (I checked) returns it this way.

Vaguely remember doing it that way for some reason, I think it's to make the limit option always return the most recent events, and then we never reverse the sort order after.

You're right it could be documented, PRs welcome!

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