From 5981448f0de68dc1938195f4fe688128e5edbf19 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Mon, 16 Oct 2023 12:55:25 +0200 Subject: add internal tag `createdAt` --- app/Issue/Tag.hs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'app/Issue/Tag.hs') diff --git a/app/Issue/Tag.hs b/app/Issue/Tag.hs index 9c0c98f..c227491 100644 --- a/app/Issue/Tag.hs +++ b/app/Issue/Tag.hs @@ -2,9 +2,11 @@ module Issue.Tag (Tag (..), extractTags, internalTags) where import Data.Binary (Binary) import Data.Maybe (catMaybes) -import Data.Text (Text) +import Data.Text (Text, pack) import Data.Text qualified as T +import Data.Time.Clock (UTCTime (utctDay)) import GHC.Generics (Generic) +import Issue.Provenance (Provenance (..)) data Tag = Tag Text Text deriving (Show, Generic, Binary) @@ -21,10 +23,19 @@ extractTags = ) . T.lines -internalTags :: Text -> [Tag] -internalTags title = - [ Tag "id" (toSpinalCase title) - ] +internalTags :: Text -> Maybe Provenance -> [Tag] +internalTags title provenance' = + concat + [ [ Tag "id" (toSpinalCase title) + ], + maybe + [] + ( \provenance -> + [ Tag "createdAt" (pack (show (utctDay provenance.date))) + ] + ) + provenance' + ] toSpinalCase :: Text -> Text toSpinalCase = T.replace " " "-" . T.filter keep . T.toLower -- cgit v1.2.3