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

Event merge from different buckets #78

Open
laszukdawid opened this issue May 12, 2019 · 4 comments
Open

Event merge from different buckets #78

laszukdawid opened this issue May 12, 2019 · 4 comments

Comments

@laszukdawid
Copy link

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:

buckets = aw_client.get_buckets()
all_events = [aw_client.get_events(bucket['id']) for bucket in buckets]
merged_events = aw_transform.merge_events(*all_events)

I need this, so if there's no such functionality, I'm happy to contribute, but maybe you already have one?

@ErikBjare
Copy link
Member

ErikBjare commented May 12, 2019

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? 🙂

@laszukdawid
Copy link
Author

laszukdawid commented May 12, 2019

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.

@johan-bjareholt
Copy link
Member

johan-bjareholt commented May 13, 2019

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.

@laszukdawid
Copy link
Author

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 :)

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

3 participants