aboutsummaryrefslogtreecommitdiffstats
path: root/app/Issue/Meta.hs
blob: 4c237a4c11c8ab00ef4db7b75a4aedeaa1b4ddd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module Issue.Meta
  ( Meta (..),
    getMeta,
  )
where

import Data.Text qualified as T
import Issue (Issue (..))
import Issue.Tag (Tag, tagValue)

data Meta = Meta
  { referencedBy :: [(Issue, Tag)]
  }
  deriving (Show)

getMeta :: [Issue] -> Issue -> Meta
getMeta issues issue =
  Meta
    { referencedBy =
        concatMap
          ( \issueOther ->
              let tagsRelevant =
                    filter (\tag -> tagValue tag == fmap T.pack issue.id) issueOther.tags
               in map (\tag -> (issueOther, tag)) tagsRelevant
          )
          issues
    }