]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/NodeNgram.hs
[FIX] double -> int for hyper data dates info.
[gargantext.git] / src / Gargantext / Database / NodeNgram.hs
1 {-# LANGUAGE TemplateHaskell #-}
2 {-# LANGUAGE FlexibleInstances #-}
3 {-# LANGUAGE MultiParamTypeClasses #-}
4 {-# LANGUAGE FunctionalDependencies #-}
5 {-# LANGUAGE Arrows #-}
6 {-# OPTIONS_GHC -fno-warn-orphans #-}
7
8
9 module Gargantext.Database.NodeNgram where
10
11 import Prelude
12 import Data.Profunctor.Product.TH (makeAdaptorAndInstance)
13 import Control.Lens.TH (makeLensesWith, abbreviatedFields)
14
15 import Opaleye
16
17 data NodeNgramPoly id node_id ngram_id weight
18 = NodeNgram { nodeNgram_NodeNgramId :: id
19 , nodeNgram_NodeNgramNodeId :: node_id
20 , nodeNgram_NodeNgramNgramId :: ngram_id
21 , nodeNgram_NodeNgramWeight :: weight
22 } deriving (Show)
23
24 type NodeNgramWrite = NodeNgramPoly (Column PGInt4 )
25 (Column PGInt4 )
26 (Column PGInt4 )
27 (Column PGFloat8)
28
29 type NodeNgramRead = NodeNgramPoly (Column PGInt4 )
30 (Column PGInt4 )
31 (Column PGInt4 )
32 (Column PGFloat8)
33
34 type NodeNgram = NodeNgramPoly Int Int Int Double
35
36 $(makeAdaptorAndInstance "pNodeNgram" ''NodeNgramPoly)
37 $(makeLensesWith abbreviatedFields ''NodeNgramPoly)
38
39
40 nodeNgramTable :: Table NodeNgramWrite NodeNgramRead
41 nodeNgramTable = Table "nodes_ngrams" ( pNodeNgram NodeNgram
42 { nodeNgram_NodeNgramId = required "id"
43 , nodeNgram_NodeNgramNodeId = required "node_id"
44 , nodeNgram_NodeNgramNgramId = required "ngram_id"
45 , nodeNgram_NodeNgramWeight = required "weight"
46 }
47 )
48
49 queryNodeNgramTable :: Query NodeNgramRead
50 queryNodeNgramTable = queryTable nodeNgramTable
51