Downgrade Waiting to not being a status

This commit is contained in:
Malte Brandy 2021-11-26 21:22:45 +01:00
parent e1f9bcd3a9
commit e8eccc0ae8
No known key found for this signature in database
GPG Key ID: 226A2D41EF5378C9
3 changed files with 5 additions and 4 deletions

View File

@ -33,7 +33,6 @@ data Status
= Pending
| Deleted {end :: UTCTime}
| Completed {end :: UTCTime}
| Waiting {wait :: UTCTime}
| Recurring
{ recur :: Text
, mask :: Mask
@ -47,7 +46,6 @@ parseFromObject o =
"pending" -> pure Pending
"deleted" -> Deleted <$> (o .: "end" >>= Time.parse)
"completed" -> Completed <$> (o .: "end" >>= Time.parse)
"waiting" -> Waiting <$> (o .: "wait" >>= Time.parse)
"recurring" -> Recurring <$> o .: "recur" <*> o .: "mask"
str -> typeMismatch "status" (Aeson.String str)
@ -57,7 +55,6 @@ toPairs = \case
Pending -> [statusLabel "pending"]
Deleted{..} -> [statusLabel "deleted", "end" .= Time.toValue end]
Completed{..} -> [statusLabel "completed", "end" .= Time.toValue end]
Waiting{..} -> [statusLabel "waiting", "wait" .= Time.toValue wait]
Recurring{..} -> [statusLabel "recurring", "recur" .= recur, "mask" .= mask]
where
statusLabel :: Text -> Pair

View File

@ -80,6 +80,7 @@ data Task = Task
, description :: Text
, start :: Maybe UTCTime
, modified :: Maybe UTCTime
, wait :: Maybe UTCTime
, due :: Maybe UTCTime
, until :: Maybe UTCTime
, annotations :: Set Annotation
@ -134,6 +135,7 @@ instance FromJSON Task where
entry <- object .: "entry" >>= Time.parse
description <- object .: "description"
start <- parseTimeFromFieldMay "start"
wait <- parseTimeFromFieldMay "wait"
modified <- parseTimeFromFieldMay "modified"
due <- parseTimeFromFieldMay "due"
until_ <- parseTimeFromFieldMay "until"
@ -185,6 +187,7 @@ instance ToJSON Task where
(\(name, value) -> (name .=) . Time.toValue <$> value)
[ ("start", start)
, ("modified", modified)
, ("wait", wait)
, ("due", due)
, ("scheduled", scheduled)
, ("until", until_)
@ -227,6 +230,7 @@ makeTask uuid entry description =
, start = Nothing
, scheduled = Nothing
, until = Nothing
, wait = Nothing
, annotations = mempty
, depends = mempty
, tags = mempty

View File

@ -48,7 +48,6 @@ instance Arbitrary Status where
[ pure Pending
, Deleted <$> arbitrary
, Completed <$> arbitrary
, Waiting <$> arbitrary
, Recurring <$> arbitrary <*> arbitrary
]
@ -81,6 +80,7 @@ instance Arbitrary Task where
entry <- arbitrary
description <- arbitrary
start <- arbitrary
wait <- arbitrary
modified <- arbitrary
due <- arbitrary
until_ <- arbitrary