diff options
| -rw-r--r-- | internal/store/availability_test.go | 33 | ||||
| -rw-r--r-- | internal/store/native_tasks_test.go | 9 | ||||
| -rw-r--r-- | internal/store/sqlite_test.go | 9 | ||||
| -rw-r--r-- | migrations/025_task_budgets_and_availability.sql | 14 |
4 files changed, 61 insertions, 4 deletions
diff --git a/internal/store/availability_test.go b/internal/store/availability_test.go new file mode 100644 index 0000000..97ce90e --- /dev/null +++ b/internal/store/availability_test.go @@ -0,0 +1,33 @@ +package store + +import ( + "database/sql" + "path/filepath" + "testing" + + _ "github.com/mattn/go-sqlite3" +) + +// newAvailabilityTestStore creates a Store backed by a fresh temp sqlite DB +// with just the availability_blocks table. +func newAvailabilityTestStore(t *testing.T) *Store { + t.Helper() + dbPath := filepath.Join(t.TempDir(), "test.db") + db, err := sql.Open("sqlite3", dbPath) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { db.Close() }) + if _, err := db.Exec(` + CREATE TABLE availability_blocks ( + id TEXT PRIMARY KEY, + weekday INTEGER NOT NULL, + start_time TEXT NOT NULL, + end_time TEXT NOT NULL, + label TEXT DEFAULT '' + ) + `); err != nil { + t.Fatal(err) + } + return &Store{db: db} +} diff --git a/internal/store/native_tasks_test.go b/internal/store/native_tasks_test.go index cf9ea49..1b4bdf2 100644 --- a/internal/store/native_tasks_test.go +++ b/internal/store/native_tasks_test.go @@ -41,7 +41,8 @@ func newNativeTasksTestStore(t *testing.T) *Store { recurrence_interval INTEGER DEFAULT 1, recurrence_weekdays TEXT DEFAULT '', recurrence_series_id TEXT DEFAULT '', - next_occurrence_override TEXT DEFAULT '' + next_occurrence_override TEXT DEFAULT '', + estimated_minutes INTEGER DEFAULT 0 ) `); err != nil { t.Fatal(err) @@ -52,7 +53,8 @@ func newNativeTasksTestStore(t *testing.T) *Store { name TEXT NOT NULL, color TEXT DEFAULT '', created_at DATETIME DEFAULT CURRENT_TIMESTAMP, - archived BOOLEAN DEFAULT 0 + archived BOOLEAN DEFAULT 0, + budget_tracked BOOLEAN DEFAULT 0 ) `); err != nil { t.Fatal(err) @@ -60,7 +62,8 @@ func newNativeTasksTestStore(t *testing.T) *Store { if _, err := db.Exec(` CREATE TABLE labels ( name TEXT PRIMARY KEY, - color TEXT NOT NULL + color TEXT NOT NULL, + budget_tracked BOOLEAN DEFAULT 0 ) `); err != nil { t.Fatal(err) diff --git a/internal/store/sqlite_test.go b/internal/store/sqlite_test.go index 3c5a7b6..345b40e 100644 --- a/internal/store/sqlite_test.go +++ b/internal/store/sqlite_test.go @@ -173,12 +173,19 @@ func setupTestStoreWithNativeTasks(t *testing.T) *Store { content TEXT NOT NULL, description TEXT DEFAULT '', project_name TEXT DEFAULT '', + project_id TEXT DEFAULT '', due_date DATETIME, priority INTEGER DEFAULT 1, completed BOOLEAN DEFAULT 0, labels TEXT DEFAULT '[]', created_at DATETIME DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME DEFAULT CURRENT_TIMESTAMP + updated_at DATETIME DEFAULT CURRENT_TIMESTAMP, + recurrence_freq TEXT DEFAULT '', + recurrence_interval INTEGER DEFAULT 1, + recurrence_weekdays TEXT DEFAULT '', + recurrence_series_id TEXT DEFAULT '', + next_occurrence_override TEXT DEFAULT '', + estimated_minutes INTEGER DEFAULT 0 ); ` if _, err := db.Exec(schema); err != nil { diff --git a/migrations/025_task_budgets_and_availability.sql b/migrations/025_task_budgets_and_availability.sql new file mode 100644 index 0000000..3fd945d --- /dev/null +++ b/migrations/025_task_budgets_and_availability.sql @@ -0,0 +1,14 @@ +-- Opt-in time-budget visibility: a manual weekly availability template, +-- per-task time estimates, and a budget-tracked flag on projects/labels so +-- only tasks the user has opted in count against any budget calculation. +CREATE TABLE availability_blocks ( + id TEXT PRIMARY KEY, + weekday INTEGER NOT NULL, -- 0-6, Sun-Sat + start_time TEXT NOT NULL, -- "18:00" + end_time TEXT NOT NULL, -- "20:00" + label TEXT DEFAULT '' +); + +ALTER TABLE native_tasks ADD COLUMN estimated_minutes INTEGER DEFAULT 0; +ALTER TABLE projects ADD COLUMN budget_tracked BOOLEAN DEFAULT 0; +ALTER TABLE labels ADD COLUMN budget_tracked BOOLEAN DEFAULT 0; |
