From ef5f4581f31ec35a4b2afefbafac56f175566879 Mon Sep 17 00:00:00 2001 From: Fabian Kirchner Date: Sat, 14 Oct 2023 12:11:38 +0200 Subject: add basic caching of Issue's --- app/Issue.hs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'app/Issue.hs') diff --git a/app/Issue.hs b/app/Issue.hs index ba8baa8..f7227f1 100644 --- a/app/Issue.hs +++ b/app/Issue.hs @@ -1,10 +1,12 @@ {-# LANGUAGE BlockArguments #-} +{-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DisambiguateRecordFields #-} {-# LANGUAGE OverloadedRecordDot #-} {-# LANGUAGE OverloadedStrings #-} module Issue (Issue (..), Provenance (..), fromMatch, id) where +import Data.Binary (Binary, get, put) import Data.ByteString.Lazy (toStrict) import Data.ByteString.Lazy.Char8 (unpack) import Data.List (find, foldl') @@ -13,6 +15,7 @@ import Data.Text (Text) import Data.Text qualified as T import Data.Text.Encoding (decodeUtf8) import Data.Time.Clock (UTCTime) +import GHC.Generics (Generic) import Issue.Tag (Tag (..)) import Issue.Tag qualified as I import Issue.Text qualified as I @@ -34,7 +37,7 @@ data Issue = Issue tags :: [Tag], internalTags :: [Tag] } - deriving (Show) + deriving (Show, Binary, Generic) data Provenance = Provenance { firstCommit :: Text, @@ -42,7 +45,12 @@ data Provenance = Provenance authorEmail :: Text, authorName :: Text } - deriving (Show) + deriving (Show, Generic, Binary) + +instance Binary UTCTime where + -- TODO Serialize UTCTime using POSIX time stamps + put = put . show + get = fmap read get id :: Issue -> Maybe String id issue = -- cgit v1.2.3