feat(store): tasks, accounts, runs, dedup journal

This commit is contained in:
2026-07-01 16:58:33 +07:00
parent 0cf9de38c4
commit 67a2367baa
5 changed files with 218 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
package store
import "context"
type Run struct {
ID int64
TaskID int64
Status string
TotalCopied int64
TotalSkipped int64
TotalErrors int64
}
func (s *Store) CreateRun(ctx context.Context, taskID int64) (int64, error) {
var id int64
err := s.Pool.QueryRow(ctx,
`INSERT INTO runs (task_id) VALUES ($1) RETURNING id`, taskID).Scan(&id)
return id, err
}
func (s *Store) FinishRun(ctx context.Context, id int64, status string, copied, skipped, errs int64) error {
_, err := s.Pool.Exec(ctx,
`UPDATE runs SET status=$2, finished_at=now(),
total_copied=$3, total_skipped=$4, total_errors=$5 WHERE id=$1`,
id, status, copied, skipped, errs)
return err
}