From 6b76050f758917cf3552c20f99a4bfedd66049f2 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Thu, 5 Oct 2023 10:30:29 +0200 Subject: show single issue by id only --- app/Issue.hs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'app/Issue.hs') diff --git a/app/Issue.hs b/app/Issue.hs index 07bddee..d163df7 100644 --- a/app/Issue.hs +++ b/app/Issue.hs @@ -3,17 +3,19 @@ {-# LANGUAGE OverloadedRecordDot #-} {-# LANGUAGE OverloadedStrings #-} -module Issue (Issue (..), fromMatch) where +module Issue (Issue (..), fromMatch, id) where +import Data.List (find) import Data.Text (Text) import Data.Text qualified as T -import Issue.Tag (Tag) +import Issue.Tag (Tag (..)) import Issue.Tag qualified as I import Issue.Text qualified as I import TreeGrepper.Match (Match (..)) import TreeGrepper.Match qualified as G import TreeGrepper.Result (Result (..)) import TreeGrepper.Result qualified as G +import Prelude hiding (id) data Issue = Issue { title :: Text, @@ -23,6 +25,14 @@ data Issue = Issue tags :: [Tag], internalTags :: [Tag] } + deriving (Show) + +id :: Issue -> Maybe String +id issue = + (\(Tag _ v) -> T.unpack v) + <$> ( find (\(Tag k _) -> k == "id") $ + issue.tags ++ issue.internalTags + ) fromMatch :: G.Result -> G.Match -> Maybe Issue fromMatch result match = -- cgit v1.2.3