aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2023-10-16 12:55:25 +0200
committerLibravatar Alexander Foremny <aforemny@posteo.de>2023-10-16 13:53:30 +0200
commit5981448f0de68dc1938195f4fe688128e5edbf19 (patch)
treeff7c1507034abdbcc6ceaeed60ed7f46253519f7
parent0391f3cb867db458e6d607facd424f627c99f437 (diff)
add internal tag `createdAt`
-rw-r--r--app/History.hs7
-rw-r--r--app/Issue.hs2
-rw-r--r--app/Issue/Tag.hs21
3 files changed, 23 insertions, 7 deletions
diff --git a/app/History.hs b/app/History.hs
index f436672..8fdbd0a 100644
--- a/app/History.hs
+++ b/app/History.hs
@@ -12,6 +12,7 @@ import Data.Text.Encoding (decodeUtf8)
import GHC.Generics (Generic)
import Issue (Issue (..), fromMatch, id)
import Issue.Filter (Filter, applyFilter)
+import Issue.Tag qualified as I
import Parallel (parMapM)
import Process (proc, sh, sh_)
import System.Directory (createDirectoryIfMissing, doesFileExist, getCurrentDirectory)
@@ -191,7 +192,11 @@ issueFromIssueEvents issueEvents =
Just issue
IssueChanged {issue} : _ -> do
issueFirst <- issueFromIssueEvent $ head $ reverse issueEvents
- pure $ issue {provenance = issueFirst.provenance}
+ pure $
+ issue
+ { provenance = issueFirst.provenance,
+ internalTags = I.internalTags issue.title issueFirst.provenance
+ }
IssueDeleted _ : _ ->
Nothing
_ ->
diff --git a/app/Issue.hs b/app/Issue.hs
index 75e700d..8804929 100644
--- a/app/Issue.hs
+++ b/app/Issue.hs
@@ -50,7 +50,7 @@ fromMatch cwd result match = do
start = match.start,
end = match.end,
tags = maybe [] I.extractTags description,
- internalTags = I.internalTags title
+ internalTags = I.internalTags title provenance
}
else Nothing
)
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