1 {-# LANGUAGE TemplateHaskell #-}
2 {-# LANGUAGE FlexibleInstances #-}
3 {-# LANGUAGE MultiParamTypeClasses #-}
4 {-# LANGUAGE FunctionalDependencies #-}
5 {-# LANGUAGE Arrows #-}
6 {-# OPTIONS_GHC -fno-warn-orphans #-}
9 module Gargantext.Database.NodeNgram where
12 import Data.Profunctor.Product.TH (makeAdaptorAndInstance)
13 import Control.Lens.TH (makeLensesWith, abbreviatedFields)
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
24 type NodeNgramWrite = NodeNgramPoly (Column PGInt4) (Column PGInt4) (Column PGInt4) (Column PGFloat8)
25 type NodeNgramRead = NodeNgramPoly (Column PGInt4) (Column PGInt4) (Column PGInt4) (Column PGFloat8)
28 type NodeNgram = NodeNgramPoly Int Int Int Double
30 $(makeAdaptorAndInstance "pNodeNgram" ''NodeNgramPoly)
31 $(makeLensesWith abbreviatedFields ''NodeNgramPoly)
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"
43 queryNodeNgramTable :: Query NodeNgramRead
44 queryNodeNgramTable = queryTable nodeNgramTable