aboutsummaryrefslogtreecommitdiffstats
path: root/app/Issue/Meta.hs
blob: 19ccab338b8ee8525c9e41a17ce895925967ff93 (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
module Issue.Meta
  ( Meta (..),
    getMeta,
  )
where

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 == Just issue.id) issueOther.tags
               in map (\tag -> (issueOther, tag)) tagsRelevant
          )
          issues
    }