Use compact classification IDs and extend preview lifetime

This commit is contained in:
Lars Nolden
2026-09-14 09:31:44 +02:00
parent 77f4ea5655
commit 46e02d95cb
8 changed files with 424 additions and 142 deletions
+4 -2
View File
@@ -13,6 +13,8 @@ import (
"finance-duck/internal/domain"
)
const previewLifetime = 24 * time.Hour
type Fields struct {
Merchant bool `json:"merchant"`
Category bool `json:"category"`
@@ -173,7 +175,7 @@ func (a *App) runPreview(ctx context.Context, cancel context.CancelFunc, client
return
}
for id, old := range a.previews {
if time.Since(old.created) > time.Hour {
if time.Since(old.created) > previewLifetime {
delete(a.previews, id)
}
}
@@ -343,7 +345,7 @@ func (a *App) ApplyPreview(ctx context.Context, id, rev string, ids []string, ed
a.mu.Lock()
defer a.mu.Unlock()
p, ok := a.previews[id]
if !ok || time.Since(p.created) > time.Hour {
if !ok || time.Since(p.created) > previewLifetime {
return State{}, errors.New("preview expired or unknown; analyse again")
}
if rev != p.Revision {