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

Add endtime to event model #49

Open
johan-bjareholt opened this issue Jan 20, 2018 · 2 comments
Open

Add endtime to event model #49

johan-bjareholt opened this issue Jan 20, 2018 · 2 comments

Comments

@johan-bjareholt
Copy link
Member

We currently have an issue when fetching events by starttime and endtime.

23:00                             00:00                           01:00
<----------------------------------------------------------------------
         | event start                                 event end |

If we have a case like this and we have an event which starts before 00:00 and ends after 00:00, if we query with startime=the_second_day we will not get the event even though it is within the second day.

Currently we are checking the datetimes like this

if event.starttime >= starttime and event.starttime <= endtime:
    return event

What we actually should do when fetching events with a starttime and endtime

if event.endtime >= starttime and event.starttime <= endtime:
    return event

This would however require us to add a "endtime" field to save in every datastore.
At that point we could also remove the duration field since it's essentially endtime-starttime to save on db size.

TL;DR: Our datastorages cannot filter by starttime+duration to get the endtime, we need an actual endtime field instead of duration to be able to filter after endtime and fix a few quirks when having events in between two dates.

@ErikBjare
Copy link
Member

I'm aware of this issue, and this is certainly a clear way to fix it but would require quite a lot of work to get done.

If we were to implement this, we'd do it in together with the other changes suggested in ActivityWatch/activitywatch#109

@ErikBjare
Copy link
Member

There might be a way to do this for the SQLite datastore by either using a view or something else that computes endtime (and makes it queryable) from timestamp and duration. Will have to investigate, but might not even require a database migration, so that would be cool.

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