From f9fddf496a3c7e6612dffb2a72db395b09c3d4e8 Mon Sep 17 00:00:00 2001 From: Justin Hawkins Date: Thu, 19 Jun 2025 10:04:43 +0200 Subject: [PATCH] Show how long the fetches took --- model.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/model.go b/model.go index 1be44ce..be12187 100644 --- a/model.go +++ b/model.go @@ -109,7 +109,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.fetchedData = false } else { - m.statusBarMessage = fmt.Sprintf("Fetched %d time entries", len(msg.TimeEntries)) + m.statusBarMessage = fmt.Sprintf("Fetched %d time entries in %s", len(msg.TimeEntries), time.Since(msg.start).Truncate(time.Millisecond)) m.timeData.entries = msg.TimeEntries m.formData.customers = msg.Customers m.formData.services = msg.Services @@ -308,6 +308,7 @@ func (m model) tableDataForDate(t time.Time) []table.Row { } type miteDataFetchedMsg struct { + start time.Time TimeEntries mite.TimeEntries Customers mite.Customers Services mite.Services @@ -317,6 +318,7 @@ type miteDataFetchedMsg struct { func (m model) fetchMiteData() tea.Cmd { return func() tea.Msg { + t0 := time.Now() from := time.Now().Add(-time.Hour * 24 * 30 * 6) // about 6 months to := time.Now().Add(time.Hour * 20 * 30) // about 1 month te, err1 := m.miteAPI.GetTimeEntries(from, to) @@ -330,6 +332,7 @@ func (m model) fetchMiteData() tea.Cmd { Services: svc, Projects: pjt, Error: errors.Join(err1, err2, err3, err4), + start: t0, } } }