]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Schema/NodeContext.hs
Merge remote-tracking branch 'origin/dev' into 376-dev-annuaire-fields
[gargantext.git] / src / Gargantext / Database / Schema / NodeContext.hs
1 {-|
2 Module : Gargantext.Database.Schema.NodeNode
3 Description :
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 Here is a longer description of this module, containing some
11 commentary with @some markup@.
12 -}
13
14 {-# OPTIONS_GHC -fno-warn-orphans #-}
15
16 {-# LANGUAGE Arrows #-}
17 {-# LANGUAGE FunctionalDependencies #-}
18 {-# LANGUAGE QuasiQuotes #-}
19 {-# LANGUAGE TemplateHaskell #-}
20
21 module Gargantext.Database.Schema.NodeContext where
22
23 import Gargantext.Core.Types
24 import Gargantext.Database.Schema.Prelude
25 import Gargantext.Database.Schema.NodeNode () -- Just importing some instances
26 import Gargantext.Prelude
27
28
29 data NodeContextPoly id node_id context_id score cat
30 = NodeContext { _nc_id :: !id
31 , _nc_node_id :: !node_id
32 , _nc_context_id :: !context_id
33 , _nc_score :: !score
34 , _nc_category :: !cat
35 } deriving (Show)
36
37 type NodeContextWrite = NodeContextPoly (Maybe (Column (SqlInt4)))
38 (Column (SqlInt4))
39 (Column (SqlInt4))
40 (Maybe (Column (SqlFloat8)))
41 (Maybe (Column (SqlInt4)))
42
43 type NodeContextRead = NodeContextPoly (Column (SqlInt4))
44 (Column (SqlInt4))
45 (Column (SqlInt4))
46 (Column (SqlFloat8))
47 (Column (SqlInt4))
48
49 type NodeContextReadNull = NodeContextPoly (Column (Nullable SqlInt4))
50 (Column (Nullable SqlInt4))
51 (Column (Nullable SqlInt4))
52 (Column (Nullable SqlFloat8))
53 (Column (Nullable SqlInt4))
54
55 type NodeContext = NodeContextPoly (Maybe Int) NodeId NodeId (Maybe Double) (Maybe Int)
56
57 $(makeAdaptorAndInstance "pNodeContext" ''NodeContextPoly)
58 makeLenses ''NodeContextPoly
59
60 nodeContextTable :: Table NodeContextWrite NodeContextRead
61 nodeContextTable =
62 Table "nodes_contexts"
63 ( pNodeContext
64 NodeContext { _nc_id = optionalTableField "id"
65 , _nc_node_id = requiredTableField "node_id"
66 , _nc_context_id = requiredTableField "context_id"
67 , _nc_score = optionalTableField "score"
68 , _nc_category = optionalTableField "category"
69 }
70 )