ActivityWatch / aw-watcher-afk

Watches keyboard and mouse activity to determine if you are AFK or not (for use with ActivityWatch)
Mozilla Public License 2.0
47 stars 31 forks source link

Data is often doubled with two events starting at same timestamp but different durations #61

Open 8Dion8 opened 1 year ago

8Dion8 commented 1 year ago

While experimenting with analysing the watcher data separately, I noticed that data often is doubled, with two events starting at identical timestamps but with different durations. Here are two screenshots demonstrating this, one from the GUI view and one from the database itself.

image

(notice the lines in the middle of the visualization of each period, there are two events there)

image

This, while it doesn't seem to affect the official visualisations much, is rather annoying to work with when working with the data directly. Seems though like this could be an easy fix even by just filtering the data afterhand with just checking the start timestamp and comparing the durations, leaving only one event, or by implementing some sort of overlap correction.

neNerower commented 1 year ago

Have the same issue. It looks like watcher stores midterm values of an event duration and doesn't overwrite them.

Also, I noticed that the "same" events can be repeated not only twice.

{
    "timestamp": "2023-04-18T11:07:59.903000+00:00",
    "duration": 354.954,
    "data": {
        "status": "afk"
    }
},
{
    "timestamp": "2023-04-18T11:07:59.903000+00:00",
    "duration": 236.826,
    "data": {
        "status": "afk"
    }
},
{
    "timestamp": "2023-04-18T11:07:59.903000+00:00",
    "duration": 241.947,
    "data": {
        "status": "afk"
    }
},
{
    "timestamp": "2023-04-18T11:07:59.903000+00:00",
    "duration": 231.729,
    "data": {
        "status": "afk"
    }
},

As well, repetitions can appear with "not-afk" events too. At first I thought the opposite.

{
    "timestamp": "2023-04-17T18:44:50.420000+00:00",
    "duration": 336.329,
    "data": {
        "status": "not-afk"
    }
},
{
    "timestamp": "2023-04-17T18:44:50.420000+00:00",
    "duration": 133.97,
    "data": {
        "status": "not-afk"
    }
},
{
    "timestamp": "2023-04-17T18:44:50.420000+00:00",
    "duration": 113.806,
    "data": {
        "status": "not-afk"
    }
},