ActivityWatch/aw-server-rust

running get_events from aw_client returns events in reverse order

skewballfox opened this issue · 1 comments

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

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!