diff options
| author | Ben Sima <ben@bensima.com> | 2025-11-22 13:52:20 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bensima.com> | 2025-11-22 13:52:20 -0500 |
| commit | 80126cbe4e93af7edda445e6c0a3b10c2ebeba6a (patch) | |
| tree | b9c866baa7190e0fed1ccf1bd781f588bf039187 /Omni/Task | |
| parent | 4857678010f47891c0637b2bcfb0889bbf3b9e01 (diff) | |
| parent | 37931a412eb300edc21188678dee984a4f5d1b3a (diff) | |
task: complete t-rWcpygi7d (Merge)
Amp-Thread-ID:
https://ampcode.com/threads/T-ca3b086b-5a85-422a-b13d-256784c04221
Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'Omni/Task')
| -rw-r--r-- | Omni/Task/Core.hs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/Omni/Task/Core.hs b/Omni/Task/Core.hs index 58744fa..3de42b2 100644 --- a/Omni/Task/Core.hs +++ b/Omni/Task/Core.hs @@ -192,7 +192,7 @@ withTaskReadLock action = action ) --- Generate a short ID using base62 encoding of timestamp +-- Generate a short ID using base36 encoding of timestamp (lowercase) generateId :: IO Text generateId = do now <- getCurrentTime @@ -339,7 +339,7 @@ createTask title taskType parent namespace priority deps description = deps' = map normalizeDependency deps tid <- case parent' of - Nothing -> generateId + Nothing -> generateUniqueId Just pid -> do tasks <- loadTasksInternal pure <| computeNextChildId tasks pid @@ -361,6 +361,18 @@ createTask title taskType parent namespace priority deps description = saveTaskInternal task pure task +-- Generate a unique ID (checking against existing tasks) +generateUniqueId :: IO Text +generateUniqueId = do + tasks <- loadTasksInternal + go tasks + where + go tasks = do + tid <- generateId + case findTask tid tasks of + Nothing -> pure tid + Just _ -> go tasks -- Retry if collision (case-insensitive) + -- Update task status updateTaskStatus :: Text -> Status -> [Dependency] -> IO () updateTaskStatus tid newStatus newDeps = |
