]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/NodeNgram.hs
[API/Count] Adding route and types.
[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) (Column PGInt4) (Column PGInt4) (Column PGFloat8)
25 type NodeNgramRead = NodeNgramPoly (Column PGInt4) (Column PGInt4) (Column PGInt4) (Column PGFloat8)
26
27
28 type NodeNgram = NodeNgramPoly Int Int Int Double
29
30 $(makeAdaptorAndInstance "pNodeNgram" ''NodeNgramPoly)
31 $(makeLensesWith abbreviatedFields ''NodeNgramPoly)
32
33
34 nodeNgramTable :: Table NodeNgramWrite NodeNgramRead
35 nodeNgramTable = Table "nodes_ngrams" (pNodeNgram NodeNgram { nodeNgram_NodeNgramId = required "id"
36 , nodeNgram_NodeNgramNodeId = required "node_id"
37 , nodeNgram_NodeNgramNgramId = required "ngram_id"
38 , nodeNgram_NodeNgramWeight = required "weight"
39 }
40 )
41
42
43 queryNodeNgramTable :: Query NodeNgramRead
44 queryNodeNgramTable = queryTable nodeNgramTable
45
46