Skip to content

Commit

Permalink
Rename zeroTask to emptyTask
Browse files Browse the repository at this point in the history
  • Loading branch information
ad-si committed May 6, 2024
1 parent a86339b commit 35f2b72
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions tasklite-core/source/FullTask.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import Task (
waiting_utc
),
TaskState,
zeroTask,
emptyTask,
)


Expand Down Expand Up @@ -235,7 +235,7 @@ selectQuery =

cpTimesAndState :: FullTask -> Task
cpTimesAndState (FullTask{..}) =
zeroTask
emptyTask
{ Task.ulid
, Task.modified_utc
, Task.awake_utc
Expand Down
4 changes: 2 additions & 2 deletions tasklite-core/source/ImportExport.hs
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ import Task (
user,
waiting_utc
),
emptyTask,
setMetadataField,
taskToEditableYaml,
textToTaskState,
zeroTask,
)
import Text.Editor (runUserEditorDWIM, yamlTemplate)
import Text.Parsec.Rfc2822 (GenericMessage (..), message)
Expand Down Expand Up @@ -199,7 +199,7 @@ data ImportTask = ImportTask
emptyImportTask :: ImportTask
emptyImportTask =
ImportTask
{ task = zeroTask
{ task = emptyTask
, notes = []
, tags = []
}
Expand Down
10 changes: 5 additions & 5 deletions tasklite-core/source/Lib.hs
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ import Task (
Task,
TaskState (..),
derivedStateToQuery,
emptyTask,
getStateHierarchy,
textToDerivedState,
zeroTask,
)
import Task qualified
import TaskToNote (TaskToNote (..))
Expand Down Expand Up @@ -513,7 +513,7 @@ addTask conf connection bodyWords = do
let
(body, tags, dueUtcMb, createdUtcMb) = parseTaskBody bodyWords
task =
zeroTask
emptyTask
{ Task.ulid = T.toLower $ show $ case createdUtcMb of
Nothing -> ulid
Just createdUtc -> setDateTime ulid createdUtc
Expand Down Expand Up @@ -557,7 +557,7 @@ logTask conf connection bodyWords = do
(body, extractedTags, dueUtcMb, createdUtcMb) = parseTaskBody bodyWords
tags = extractedTags <> ["log"]
task =
zeroTask
emptyTask
{ Task.ulid = T.toLower $ show $ case createdUtcMb of
Nothing -> ulid
Just createdUtc -> setDateTime ulid createdUtc
Expand Down Expand Up @@ -608,7 +608,7 @@ execWithTask conf connection idSubstr callback = do
pure $
"⚠️ Task" <+> quote (prefix <> idSubstr) <+> "does not exist"
| numOfTasks == 1 ->
callback $ fromMaybe zeroTask $ P.head tasks
callback $ fromMaybe emptyTask $ P.head tasks
| numOfTasks > 1 ->
pure $
"⚠️ Id slice"
Expand Down Expand Up @@ -2042,7 +2042,7 @@ duplicateTasks conf connection ids = do
user <- getEffectiveUserName

let dupeTask =
zeroTask
emptyTask
{ Task.ulid = dupeUlid
, Task.body = task.body
, Task.modified_utc = modified_utc
Expand Down
4 changes: 2 additions & 2 deletions tasklite-core/source/Task.hs
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ instance Arbitrary Task where
arbitrary = genericArbitraryU


zeroTask :: Task
zeroTask =
emptyTask :: Task
emptyTask =
Task
{ ulid = ""
, body = ""
Expand Down
16 changes: 8 additions & 8 deletions tasklite-core/test/LibSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ import Task (
user
),
TaskState (Done),
zeroTask,
emptyTask,
)
import TaskToNote (TaskToNote (TaskToNote, ulid))
import TaskToNote qualified
Expand All @@ -95,7 +95,7 @@ import Utils (parseUtc)

exampleTask :: Task
exampleTask =
zeroTask
emptyTask
{ Task.ulid = "01hq68smfe0r9entg3x4rb9441"
, Task.body = "Buy milk"
, Task.state = Nothing
Expand All @@ -108,15 +108,15 @@ exampleTask =

task1 :: Task
task1 =
zeroTask
emptyTask
{ Task.ulid = "01hs68z7mdg4ktpxbv0yfafznq"
, Task.body = "New task 1"
}


taskMultiLine :: Task
taskMultiLine =
zeroTask
emptyTask
{ Task.ulid = "01hx48cnjhp18mts3c44zk3gen"
, Task.body =
"New task\n\
Expand Down Expand Up @@ -146,7 +146,7 @@ spec conf now = do
it "inserts a task" $ do
withMemoryDb conf $ \memConn -> do
let task =
zeroTask
emptyTask
{ Task.ulid = "01hrvhc0h1pncbczxym16642mm"
, Task.body = "Directly inserted task"
, Task.state = Just Done
Expand All @@ -166,7 +166,7 @@ spec conf now = do
it "updates a task" $ do
withMemoryDb conf $ \memConn -> do
let initialTask =
zeroTask
emptyTask
{ Task.ulid = "01hrvhdddfwsrnp6dd8h7tp8h4"
, Task.body = "New task"
, Task.state = Just Done
Expand Down Expand Up @@ -385,7 +385,7 @@ spec conf now = do
withMemoryDb defaultConfig $ \memConn -> do
let
task2 =
zeroTask
emptyTask
{ Task.ulid = "01hs690f9hkzk9z7zews9j2k1d"
, Task.body = "New task 2"
}
Expand All @@ -412,7 +412,7 @@ spec conf now = do
withMemoryDb defaultConfig $ \memConn -> do
let
task2 =
zeroTask
emptyTask
{ Task.ulid = "01hs6zsf3c0vqx6egfnmbqtmvy"
, Task.body = "New task 2"
, Task.closed_utc = Just "2024-04-10T18:54:10Z"
Expand Down
4 changes: 2 additions & 2 deletions tasklite-core/test/TypesSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import FullTask (FullTask (body, notes, tags, ulid), emptyFullTask)
import Lib (insertNotes, insertRecord, insertTags)
import NeatInterpolation (trimming)
import Note (Note (Note, body, ulid))
import Task (Task (body, ulid), taskToEditableYaml, zeroTask)
import Task (Task (body, ulid), emptyTask, taskToEditableYaml)
import TestUtils (withMemoryDb)


Expand Down Expand Up @@ -42,7 +42,7 @@ spec = do
describe "Task" $ do
let
sampleTask =
zeroTask
emptyTask
{ Task.ulid = "01hs68z7mdg4ktpxbv0yfafznq"
, Task.body = "Sample task"
}
Expand Down
4 changes: 2 additions & 2 deletions tasklite-core/test/UtilsSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ import Test.Hspec (SpecWith, describe, it, shouldBe)

import Task (
Task (body, due_utc, metadata, modified_utc, state, ulid, user),
zeroTask,
emptyTask,
)
import Utils (parseUlidText, parseUlidUtcSection)


exampleTask :: Task
exampleTask =
zeroTask
emptyTask
{ ulid = "01hq68smfe0r9entg3x4rb9441"
, body = "Buy milk"
, state = Nothing
Expand Down

0 comments on commit 35f2b72

Please sign in to comment.