diff options
author | Florian Klink <flokli@flokli.de> | 2019-11-27T12·02+0100 |
---|---|---|
committer | Florian Klink <flokli@flokli.de> | 2019-11-27T12·02+0100 |
commit | 87d09f616399fbe290ac466f283accad49df32f8 (patch) | |
tree | 7b1157038dc165f89a32961e0f9969021e224a37 /submitqueue | |
parent | 089e551b725dea1b062e00118ee852b655d936cd (diff) |
submitqueue: Result: record startTime during a new MakeResult constructor, return EndTime properly
even without any LogEntries
Diffstat (limited to 'submitqueue')
-rw-r--r-- | submitqueue/submitqueue.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/submitqueue/submitqueue.go b/submitqueue/submitqueue.go index 2676e237d957..8386f555e778 100644 --- a/submitqueue/submitqueue.go +++ b/submitqueue/submitqueue.go @@ -163,13 +163,23 @@ type Result struct { LogEntries []*logrus.Entry Series []Serie Error error + startTime time.Time +} + +func MakeResult() *Result { + return &Result{ + startTime: time.Now(), + } } func (r Result) StartTime() time.Time { - return r.LogEntries[0].Time + return r.startTime } func (r Result) EndTime() time.Time { + if len(r.LogEntries) == 0 { + return r.startTime + } return r.LogEntries[len(r.LogEntries)-1].Time } @@ -184,7 +194,7 @@ func (r *Result) Levels() []logrus.Level { // Run starts the submit and rebase logic. func (s *SubmitQueue) Run(fetchOnly bool) *Result { - r := &Result{} + r := MakeResult() //TODO: log decisions made and add to some ring buffer var err error |