From 274cd562f6591c9a6c31513775a974e7b78b7a14 Mon Sep 17 00:00:00 2001 From: niklas Date: Wed, 19 Aug 2020 01:13:26 +0200 Subject: [PATCH 1/2] Fix generation of wrong slot end times Previously, the time of the next slot always became the end time of the previous one. This created huge slots when the computer was on standby for some amount of time, falsely logging the last program for a much longer time than it was used. --- show.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/show.go b/show.go index eacb513..72ba85e 100644 --- a/show.go +++ b/show.go @@ -150,10 +150,10 @@ func NewTimeline(stream *Stream, labelFunc func(*Window) string) *Timeline { { if win := windows[snap.Active]; win != nil { winLabel := labelFunc(win) - if lastActive != nil && lastActive.Label == winLabel { + if lastActive != nil && lastActive.Label == winLabel && snap.Time.Sub(lastActive.Start).Minutes() < 5 { lastActive.End = snap.Time } else { - if lastActive != nil { + if lastActive != nil && snap.Time.Sub(lastActive.Start).Minutes() < 5 { lastActive.End = snap.Time } newRange := &Range{Label: winLabel, Start: snap.Time, End: snap.Time} @@ -166,7 +166,9 @@ func NewTimeline(stream *Stream, labelFunc func(*Window) string) *Timeline { } for _, prevRange := range lastVisible { - prevRange.End = snap.Time + if snap.Time.Sub(prevRange.Start).Minutes() < 5 { + prevRange.End = snap.Time + } } nextVisible := make(map[string]*Range) for _, v := range snap.Visible { @@ -185,7 +187,9 @@ func NewTimeline(stream *Stream, labelFunc func(*Window) string) *Timeline { lastVisible = nextVisible for _, prevRange := range lastOther { - prevRange.End = snap.Time + if snap.Time.Sub(prevRange.Start).Minutes() < 5 { + prevRange.End = snap.Time + } } nextOther := make(map[string]*Range) for _, win := range snap.Windows { From 58a3428f8e56845b335712a292a235784e6ba25c Mon Sep 17 00:00:00 2001 From: niklasbuehler Date: Fri, 21 Aug 2020 13:33:18 +0200 Subject: [PATCH 2/2] Fix issue with pausing time slots after 5 minutes --- show.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/show.go b/show.go index 72ba85e..c28c930 100644 --- a/show.go +++ b/show.go @@ -150,7 +150,7 @@ func NewTimeline(stream *Stream, labelFunc func(*Window) string) *Timeline { { if win := windows[snap.Active]; win != nil { winLabel := labelFunc(win) - if lastActive != nil && lastActive.Label == winLabel && snap.Time.Sub(lastActive.Start).Minutes() < 5 { + if lastActive != nil && lastActive.Label == winLabel { lastActive.End = snap.Time } else { if lastActive != nil && snap.Time.Sub(lastActive.Start).Minutes() < 5 {