Use compact classification IDs and extend preview lifetime
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user