diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-07-18 09:38:26 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-07-18 09:38:26 +0000 |
| commit | 92909ebed5df68908f32c899de1e480f8d7fb01f (patch) | |
| tree | 15fe3e0d69c2967d0b449101ff2384187b239c4e /internal/store/buckets.go | |
| parent | f08f06bef47aac2c9effb4cec650d99c2deb2dd7 (diff) | |
Add bucket CRUD and read-only Projects/Labels to Settings page
New "Maintenance Buckets" section: create a bucket, add a pool item by
title (creates the task and assigns it in one step), remove an item,
delete a bucket (unbuckets its tasks rather than deleting them).
New read-only Projects and Labels sections (name + color swatch) --
both are simple enough that read-only is the right call on web, per
user direction, rather than duplicating the Android popup's editing
UX.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZ7ikw2ukGJFTHE3bJS7zL
Diffstat (limited to 'internal/store/buckets.go')
| -rw-r--r-- | internal/store/buckets.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/internal/store/buckets.go b/internal/store/buckets.go index 8bbcca9..1e3ce9a 100644 --- a/internal/store/buckets.go +++ b/internal/store/buckets.go @@ -89,6 +89,51 @@ func (s *Store) RemoveBucketItem(taskID string) error { return checkRowsAffected(result) } +// GetBucketItems returns every task in a bucket's pool (dormant and active +// both), active first, then by priority -- backs the bucket-management view. +func (s *Store) GetBucketItems(bucketID string) ([]models.Task, error) { + rows, err := s.db.Query(` + SELECT id, content, description, project_name, project_id, due_date, priority, completed, labels, created_at, + recurrence_freq, recurrence_interval, recurrence_weekdays, recurrence_series_id, next_occurrence_override, estimated_minutes, + chain_id, chain_position, chain_unlocked, + bucket_id, bucket_state, bucket_last_active_at + FROM native_tasks + WHERE bucket_id = ? + ORDER BY (bucket_state = 'active') DESC, priority DESC + `, bucketID) + if err != nil { + return nil, err + } + defer func() { _ = rows.Close() }() + return scanNativeTasks(rows) +} + +// DeleteBucket removes a bucket and returns every member task to being a +// plain, unbucketed task (clearing bucket_id/bucket_state/ +// bucket_last_active_at) rather than deleting them. Returns +// ErrNativeTaskNotFound if id doesn't match any row. +func (s *Store) DeleteBucket(id string) error { + tx, err := s.db.Begin() + if err != nil { + return err + } + defer func() { _ = tx.Rollback() }() + + if _, err := tx.Exec(` + UPDATE native_tasks SET bucket_id = '', bucket_state = '', bucket_last_active_at = NULL, updated_at = ? WHERE bucket_id = ? + `, config.Now(), id); err != nil { + return err + } + result, err := tx.Exec(`DELETE FROM maintenance_buckets WHERE id = ?`, id) + if err != nil { + return err + } + if err := checkRowsAffected(result); err != nil { + return err + } + return tx.Commit() +} + // selectBucketCycle activates the top pick_n dormant items in the bucket's // pool, scored by staleness (never-activated items first, then oldest // bucket_last_active_at) with task priority as a tiebreaker. Activated items |
