fix refresh
This commit is contained in:
@@ -21,11 +21,10 @@ type Fields struct {
|
||||
Tags bool `json:"tags"`
|
||||
}
|
||||
type PreviewRequest struct {
|
||||
Revision string `json:"revision"`
|
||||
From string `json:"from"`
|
||||
To string `json:"to"`
|
||||
Model string `json:"model"`
|
||||
Fields Fields `json:"fields"`
|
||||
From string `json:"from"`
|
||||
To string `json:"to"`
|
||||
Model string `json:"model"`
|
||||
Fields Fields `json:"fields"`
|
||||
}
|
||||
type Change struct {
|
||||
ID string `json:"id"`
|
||||
@@ -119,12 +118,11 @@ func previewEligible(t domain.Transaction, r PreviewRequest) bool {
|
||||
t.Enrichment.Kind != "transfer" && t.Enrichment.Kind != domain.KindInvestment
|
||||
}
|
||||
|
||||
// StartPreview validates the request against the current journal and starts a
|
||||
// background classification run. The provider is paced to one request every
|
||||
// few seconds, so any real range takes minutes: the caller polls
|
||||
// PreviewProgress instead of holding an HTTP request open for the duration.
|
||||
// Only one run exists at a time; the run owns its own snapshot and never
|
||||
// touches canonical data.
|
||||
// StartPreview takes a fresh journal snapshot and starts a read-only
|
||||
// classification run. It does not require the page's revision: a sync or edit
|
||||
// while the page is open must not block analysis. ApplyPreview checks for
|
||||
// conflicting changes before writing. Only one run exists at a time; callers
|
||||
// poll PreviewProgress instead of holding an HTTP request open.
|
||||
func (a *App) StartPreview(ctx context.Context, r PreviewRequest) (PreviewProgress, error) {
|
||||
if err := validatePreviewRequest(r); err != nil {
|
||||
return PreviewProgress{}, err
|
||||
@@ -138,9 +136,6 @@ func (a *App) StartPreview(ctx context.Context, r PreviewRequest) (PreviewProgre
|
||||
if err != nil {
|
||||
return PreviewProgress{}, err
|
||||
}
|
||||
if r.Revision != s.Revision {
|
||||
return PreviewProgress{}, errors.New("revision conflict: reload before analysing")
|
||||
}
|
||||
client := a.classifier.WithModel(r.Model)
|
||||
total := 0
|
||||
for _, t := range s.Data.Transactions {
|
||||
|
||||
Reference in New Issue
Block a user