Open laszukdawid opened 5 years ago
If you are fine with overlapping events, you could just concatenate the results of aw_client.get_events()
. Is that not what you want?
merge_events
does something more complicated, it merges overlapping/adjacent events from several sources into each other without any regard for the data in those events.
Since it's not well defined which event data should end up in the resulting list of events, we clear it to ensure people don't unexpectedly end up with corrupted data.
The docs should probably reflect this.
Did this answer your question? May I ask what it is you're trying to do? 🙂
I want all overlapping events (from different sources) to be merged into a list of finer granularity and merged data.
Using the analogy from the source code, assume synchronous heartbeats and two set of sources, Firefox (F) and window (W), they'll have 2 and 1 events respectively.
F -- |
W ----
M ==-+
Where M is a data merge for all events. It will contain three events: (F- W-), (W-) and (F| W-). Consider the use case when you're using Firefox (aw-watcher-window gives only app
and title
) and you want to augment all events with all information available, i.e. url
from "aw-watcher-firefox".
Regarding:
Since it's not well defined which event data should end up in the resulting list of events, we clear it to ensure people don't unexpectedly end up with corrupted data.
You create a new list of all events' data :)
May I ask what it is you're trying to do?
I'm trying to get a more holistic view of all my activity. Immediate task is to have a "Productivity" overview of a day and merge info from many devices into Exist.io dashboard. WIP hack pack.
We don't have any transform function exactly like that currently, but it could be added.
How we currently do requests in the webui can be found here:
https://github.com/ActivityWatch/aw-webui/blob/master/src/queries.js
Where M is a data merge for all events. It will contain three events: (F- W-), (W-) and (F| W-). Consider the use case when you're using Firefox (aw-watcher-window gives only app and title) and you want to augment all events with all information available, i.e. url from "aw-watcher-firefox".
The usefulness of the data from such an transform would be questionable as the duration field would be wrong. In aw-webui we intersect the non-afk events with the window events to only get the users active time in an app and then for the browser we intersect the window data where the app is Firefox/Chrome with the aw-watcher-web data to only get the active time where the user is focusing the browser window. We do this because of modularity and because aw-watcher-web simply does not have permissions to access things such as if the window is currently moving, last mouse movement or keypress to know if the user is not afk.
However, you could of course also apply these transforms and then use your suggested transform on top of the transformed data to get something useful from it.
Apologies for the delay. I don't have much time currently to get familiar with aw-*
but I'm working in spare hours on my own project. If you want, feel free to copy my merge_events function. Or, feel free to point where you want to add this and I can make a pull request.
That's a separate topic, but in general, running aw-*
is power heavily. At least there should be "pause" buttons on plugins and preferably some switch between different operation levels. That's addition and once I'm done with my MVP I'd be happy to help if needed :)
I'm guessing this has come up many times, so apologies for not finding related issue. The closest one is in ActivityWatch but it's not exactly that :(
I found code that does the union on events but it has a note
WARNING: This function strips all data from events as it cannot keep it consistent.
Do you know/remember why is that?What I'd like to do is to have a list of events that contain all data from all buckets. Something like:
I need this, so if there's no such functionality, I'm happy to contribute, but maybe you already have one?