Make snapshot projections self-diagnosing
CI / Test (rest) (pull_request) Successful in 40s
CI / Test (store) (pull_request) Successful in 42s
CI / Lint (pull_request) Successful in 11s
CI / Build (windows/amd64) (pull_request) Successful in 8s
CI / Build (linux/arm64) (pull_request) Successful in 7s
CI / Build (linux/amd64) (pull_request) Successful in 8s
CI / Test (server-http) (pull_request) Successful in 1m32s
e2e / Playwright vs docker-compose (pull_request) Successful in 1m26s
CI / Test (rest) (pull_request) Successful in 40s
CI / Test (store) (pull_request) Successful in 42s
CI / Lint (pull_request) Successful in 11s
CI / Build (windows/amd64) (pull_request) Successful in 8s
CI / Build (linux/arm64) (pull_request) Successful in 7s
CI / Build (linux/amd64) (pull_request) Successful in 8s
CI / Test (server-http) (pull_request) Successful in 1m32s
e2e / Playwright vs docker-compose (pull_request) Successful in 1m26s
This commit is contained in:
@@ -39,6 +39,27 @@ type RunningJobActivity struct {
|
||||
LastActivity time.Time
|
||||
}
|
||||
|
||||
// LatestSuccessfulRepoMutation returns the newest completion time for a job
|
||||
// that can change the repository's snapshot projection.
|
||||
func (s *Store) LatestSuccessfulRepoMutation(ctx context.Context, hostID string) (*time.Time, error) {
|
||||
var raw sql.NullString
|
||||
err := s.db.QueryRowContext(ctx, `
|
||||
SELECT MAX(finished_at) FROM jobs
|
||||
WHERE host_id = ? AND status = 'succeeded'
|
||||
AND kind IN ('backup', 'forget', 'prune')`, hostID).Scan(&raw)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("store: latest successful repo mutation: %w", err)
|
||||
}
|
||||
if !raw.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
t, err := time.Parse(time.RFC3339Nano, raw.String)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("store: parse latest repo mutation: %w", err)
|
||||
}
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
// ListRunningJobActivity returns every running job with its latest persisted
|
||||
// activity. Jobs without started_at are excluded because they have not actually
|
||||
// entered the running state coherently and cannot be aged safely here.
|
||||
|
||||
Reference in New Issue
Block a user