2 Module : Gargantext.Database
3 Description : Tools for Database
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
10 Target: just import this module and nothing else to work with
11 Gargantext's database.
13 TODO: configure nodes table in Haskell (Config typenames etc.)
16 {-# LANGUAGE NoImplicitPrelude #-}
18 module Gargantext.Database.Config
22 import Data.Text (pack)
23 import Data.Tuple.Extra (swap)
24 import Data.Maybe (fromMaybe)
25 import Data.List (lookup)
27 import Gargantext.Database.Types.Node
28 import Gargantext.Prelude
30 nodeTypeId :: NodeType -> NodeTypeId
49 -- NodeOccurrences -> 10
67 -- NodeFavorites -> 15
71 -- | Nodes are typed in the database according to a specific ID
73 nodeTypeInv :: [(NodeTypeId, NodeType)]
74 nodeTypeInv = map swap nodeTypes
76 nodeTypes :: [(NodeType, NodeTypeId)]
77 nodeTypes = [ (n, nodeTypeId n) | n <- allNodeTypes ]
79 typeId2node :: NodeTypeId -> NodeType
80 typeId2node tId = fromMaybe (panic $ pack $ "Type Id " <> show tId <> " does not exist")
81 (lookup tId nodeTypeInv)