]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Config.hs
[NGRAMS] Table queries ready (qualitative tests, needs more tests)
[gargantext.git] / src / Gargantext / Database / Config.hs
1 {-|
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
8 Portability : POSIX
9
10 Target: just import this module and nothing else to work with
11 Gargantext's database.
12
13 TODO: configure nodes table in Haskell (Config typenames etc.)
14 -}
15
16 {-# LANGUAGE NoImplicitPrelude #-}
17
18 module Gargantext.Database.Config
19 where
20
21
22 import Data.Text (pack)
23 import Data.Tuple.Extra (swap)
24 import Data.Maybe (fromMaybe)
25 import Data.List (lookup)
26
27 import Gargantext.Database.Types.Node
28 import Gargantext.Prelude
29
30 nodeTypeId :: NodeType -> NodeTypeId
31 nodeTypeId n =
32 case n of
33 NodeUser -> 1
34 NodeFolder -> 2
35 NodeCorpusV3 -> 3
36 NodeCorpus -> 30
37 NodeAnnuaire -> 31
38 NodeDocument -> 4
39 NodeContact -> 41
40 --NodeSwap -> 19
41
42 ---- Lists
43 NodeList -> 5
44
45 ---- Scores
46 -- NodeOccurrences -> 10
47 NodeGraph -> 9
48 NodeDashboard -> 5
49 NodeChart -> 51
50
51 -- Cooccurrences -> 9
52 --
53 -- Specclusion -> 11
54 -- Genclusion -> 18
55 -- Cvalue -> 12
56 --
57 -- TfidfCorpus -> 13
58 -- TfidfGlobal -> 14
59 --
60 -- TirankLocal -> 16
61 -- TirankGlobal -> 17
62
63 -- Node management
64 -- NodeFavorites -> 15
65
66
67 --
68 -- | Nodes are typed in the database according to a specific ID
69 --
70 nodeTypeInv :: [(NodeTypeId, NodeType)]
71 nodeTypeInv = map swap nodeTypes
72
73 nodeTypes :: [(NodeType, NodeTypeId)]
74 nodeTypes = [ (n, nodeTypeId n) | n <- allNodeTypes ]
75
76 fromNodeTypeId :: NodeTypeId -> NodeType
77 fromNodeTypeId tId = fromMaybe (panic $ pack $ "Type Id " <> show tId <> " does not exist")
78 (lookup tId nodeTypeInv)