2 Commits
0.0.3 ... 0.0.4

Author SHA1 Message Date
d7f0ac16d4 Show version info
All checks were successful
CI / test (push) Successful in 1m10s
2025-06-19 10:34:35 +02:00
f9fddf496a Show how long the fetches took
All checks were successful
CI / test (push) Successful in 58s
2025-06-19 10:04:43 +02:00

View File

@@ -32,6 +32,8 @@ const MODE_CAL tuiMode = "MODE_CAL"
const MODE_TIMEENTRIES tuiMode = "MODE_TIMEENTRIES"
const MODE_FORMENTRY tuiMode = "MODE_FORMENTRY"
var version = "dev"
type model struct {
miteAPI mite.APIClient
start calendarTime
@@ -109,7 +111,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 +310,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 +320,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 +334,7 @@ func (m model) fetchMiteData() tea.Cmd {
Services: svc,
Projects: pjt,
Error: errors.Join(err1, err2, err3, err4),
start: t0,
}
}
}
@@ -399,7 +404,16 @@ func (m model) View() string {
sofar := lipgloss.Height(out)
statusMsg := strings.ReplaceAll(m.statusBarMessage, "\n", " ")
out += styleStatusBar.MarginTop(m.windowHeight - sofar).Width(m.windowWidth).Render(statusMsg)
mainMsg := styleStatusBar.Width(m.windowWidth - len(version)).MarginTop(m.windowHeight - sofar).Render(statusMsg)
versionMsg := styleStatusBar.MarginTop(m.windowHeight - sofar).Render(version)
bar := lipgloss.JoinHorizontal(lipgloss.Top,
mainMsg,
versionMsg,
)
out += bar
return out
}