diff options
Diffstat (limited to 'app/Issue')
-rw-r--r-- | app/Issue/Filter.hs | 3 | ||||
-rw-r--r-- | app/Issue/Sort.hs | 2 | ||||
-rw-r--r-- | app/Issue/Tag.hs | 10 |
3 files changed, 9 insertions, 6 deletions
diff --git a/app/Issue/Filter.hs b/app/Issue/Filter.hs index c330407..fb6d205 100644 --- a/app/Issue/Filter.hs +++ b/app/Issue/Filter.hs @@ -7,6 +7,7 @@ where import Control.Applicative (liftA2) import Control.Arrow (second) +import Data.Maybe (fromMaybe) import Data.Text (Text) import Data.Text qualified as T import Issue (Issue (..)) @@ -63,4 +64,4 @@ simpleFilterPredicate :: SimpleFilter -> (Issue -> Bool) simpleFilterPredicate (ByTag k v) i = any ((&&) <$> matchKey <*> matchValue) i.tags where matchKey (Tag k' _) = k' == k - matchValue (Tag _ v') = maybe True ((==) v') v + matchValue (Tag _ v') = fromMaybe True ((==) <$> v' <*> v) diff --git a/app/Issue/Sort.hs b/app/Issue/Sort.hs index 1a0b3ff..2195244 100644 --- a/app/Issue/Sort.hs +++ b/app/Issue/Sort.hs @@ -63,6 +63,6 @@ applySortBy :: SortBy -> Issue -> [Text] applySortBy (SortByTag k) i = sort ( mapMaybe - (\(Tag k' v) -> if k' == k then Just v else Nothing) + (\(Tag k' v) -> if k' == k then v else Nothing) (i.tags ++ i.internalTags) ) diff --git a/app/Issue/Tag.hs b/app/Issue/Tag.hs index c227491..8b6d6d4 100644 --- a/app/Issue/Tag.hs +++ b/app/Issue/Tag.hs @@ -8,7 +8,7 @@ import Data.Time.Clock (UTCTime (utctDay)) import GHC.Generics (Generic) import Issue.Provenance (Provenance (..)) -data Tag = Tag Text Text deriving (Show, Generic, Binary) +data Tag = Tag Text (Maybe Text) deriving (Show, Generic, Binary) extractTags :: Text -> [Tag] extractTags = @@ -16,7 +16,9 @@ extractTags = . map ( ( \case ((T.uncons -> Just ('@', k)) : v) -> - Just (Tag k (T.unwords v)) + case T.strip (T.unwords v) of + "" -> Just (Tag k Nothing) + v' -> Just (Tag k (Just v')) _ -> Nothing ) . T.words @@ -26,12 +28,12 @@ extractTags = internalTags :: Text -> Maybe Provenance -> [Tag] internalTags title provenance' = concat - [ [ Tag "id" (toSpinalCase title) + [ [ Tag "id" $ Just $ toSpinalCase title ], maybe [] ( \provenance -> - [ Tag "createdAt" (pack (show (utctDay provenance.date))) + [ Tag "createdAt" $ Just $ pack $ show $ utctDay provenance.date ] ) provenance' |