Simplify codebase per audit of 8b89f14
This commit is contained in:
+2
-12
@@ -72,28 +72,18 @@ func (s *Store) GetInboxItem(ctx context.Context, id string) (api.InboxItem, err
|
||||
}
|
||||
|
||||
type InboxFilter struct {
|
||||
ProjectID string
|
||||
TaskID string
|
||||
SessionID string
|
||||
State api.InboxState
|
||||
TaskID string
|
||||
State api.InboxState
|
||||
}
|
||||
|
||||
func (s *Store) ListInbox(ctx context.Context, f InboxFilter) ([]api.InboxItem, error) {
|
||||
where := []string{"state = ?"}
|
||||
args := []any{string(f.State)}
|
||||
|
||||
if f.ProjectID != "" {
|
||||
where = append(where, "project_id = ?")
|
||||
args = append(args, f.ProjectID)
|
||||
}
|
||||
if f.TaskID != "" {
|
||||
where = append(where, "task_id = ?")
|
||||
args = append(args, f.TaskID)
|
||||
}
|
||||
if f.SessionID != "" {
|
||||
where = append(where, "agent_session_id = ?")
|
||||
args = append(args, f.SessionID)
|
||||
}
|
||||
|
||||
ids, err := queryIDs(ctx, s.db, `SELECT id FROM inbox_items WHERE `+strings.Join(where, " AND ")+` ORDER BY created_at`, args...)
|
||||
if err != nil {
|
||||
|
||||
@@ -41,24 +41,6 @@ func (s *Store) CreateSnapshot(ctx context.Context, snap api.Snapshot, projectID
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Store) ListSnapshots(ctx context.Context, taskID string) ([]api.Snapshot, error) {
|
||||
rows, err := s.db.QueryContext(ctx, `SELECT `+snapshotColumns+` FROM snapshots WHERE task_id = ? ORDER BY n`, taskID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
snaps := []api.Snapshot{}
|
||||
for rows.Next() {
|
||||
snap, err := scanSnapshot(rows)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
snaps = append(snaps, snap)
|
||||
}
|
||||
return snaps, rows.Err()
|
||||
}
|
||||
|
||||
func (s *Store) GetSnapshot(ctx context.Context, taskID string, n int) (api.Snapshot, error) {
|
||||
snap, err := scanSnapshot(s.db.QueryRowContext(ctx, `SELECT `+snapshotColumns+` FROM snapshots WHERE task_id = ? AND n = ?`, taskID, n))
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
|
||||
Reference in New Issue
Block a user