Co-authored-by: David Gwilliam <dhgwilliam@gmail.com> Co-committed-by: David Gwilliam <dhgwilliam@gmail.com>
This commit was merged in pull request #36.
This commit is contained in:
@@ -3140,6 +3140,39 @@ func (k *KnoxDB) CountJunkCandidates() (int, error) {
|
||||
return n, err
|
||||
}
|
||||
|
||||
// ExpireSnippets rejects uncurated candidates discovered before the cutoff.
|
||||
// This is retention, not judgement: the code did not change, the review window
|
||||
// moved past it. Encoded and already-rejected rows are untouched, and the
|
||||
// decision is reversible with knox snippets reopen.
|
||||
func (k *KnoxDB) ExpireSnippets(cutoff time.Time, reason string) (int, error) {
|
||||
if strings.TrimSpace(reason) == "" {
|
||||
reason = "Expired: never curated within the retention window."
|
||||
}
|
||||
now := time.Now().UTC().Format(time.RFC3339)
|
||||
res, err := k.db.Exec(
|
||||
`UPDATE snippets SET status='rejected', reject_reason=?, reviewed_at=?
|
||||
WHERE status='candidate' AND superseded_by=''
|
||||
AND datetime(discovered_at) < datetime(?)`,
|
||||
reason, now, cutoff.UTC().Format(time.RFC3339),
|
||||
)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("expire snippets: %w", err)
|
||||
}
|
||||
n, _ := res.RowsAffected()
|
||||
return int(n), nil
|
||||
}
|
||||
|
||||
// CountExpiredCandidates is the actionable expiry count for a cutoff.
|
||||
func (k *KnoxDB) CountExpiredCandidates(cutoff time.Time) (int, error) {
|
||||
var n int
|
||||
err := k.db.QueryRow(
|
||||
`SELECT COUNT(*) FROM snippets WHERE status='candidate' AND superseded_by=''
|
||||
AND datetime(discovered_at) < datetime(?)`,
|
||||
cutoff.UTC().Format(time.RFC3339),
|
||||
).Scan(&n)
|
||||
return n, err
|
||||
}
|
||||
|
||||
// ReopenRejectedTechniques returns every rejected technique (bash-sourced) to the
|
||||
// candidate queue — undoing the earlier junk sweep that discarded exploration
|
||||
// and troubleshooting commands. Returns the number reopened.
|
||||
|
||||
Reference in New Issue
Block a user