2 Module : Gargantext.Database.Schema.NodeNodeNgrams
3 Description : TODO: remove this module and table in database
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
12 {-# LANGUAGE NoImplicitPrelude #-}
13 {-# LANGUAGE TemplateHaskell #-}
14 {-# LANGUAGE FlexibleInstances #-}
15 {-# LANGUAGE MultiParamTypeClasses #-}
16 {-# LANGUAGE FunctionalDependencies #-}
17 {-# LANGUAGE Arrows #-}
18 {-# OPTIONS_GHC -fno-warn-orphans #-}
21 module Gargantext.Database.Schema.NodeNodeNgrams
25 import Data.Maybe (Maybe)
26 import Data.Profunctor.Product.TH (makeAdaptorAndInstance)
27 import Control.Lens.TH (makeLensesWith, abbreviatedFields)
28 import Gargantext.Database.Utils (Cmd, runOpaQuery)
33 data NodeNodeNgramsPoly node1_id node2_id ngram_id score
34 = NodeNodeNgrams { nnng_node1_id :: node1_id
35 , nnng_node2_id :: node2_id
36 , nnng_ngrams_id :: ngram_id
41 type NodeNodeNgramsWrite = NodeNodeNgramsPoly (Column PGInt4 )
44 (Maybe (Column PGFloat8))
46 type NodeNodeNgramsRead = NodeNodeNgramsPoly (Column PGInt4 )
51 type NodeNodeNgramsReadNull = NodeNodeNgramsPoly (Column (Nullable PGInt4 ))
52 (Column (Nullable PGInt4 ))
53 (Column (Nullable PGInt4 ))
54 (Column (Nullable PGFloat8))
56 type NodeNodeNgrams = NodeNodeNgramsPoly Int
62 $(makeAdaptorAndInstance "pNodeNodeNgrams" ''NodeNodeNgramsPoly)
63 $(makeLensesWith abbreviatedFields ''NodeNodeNgramsPoly)
65 nodeNodeNgramsTable :: Table NodeNodeNgramsWrite NodeNodeNgramsRead
66 nodeNodeNgramsTable = Table "nodes_nodes_ngrams"
67 ( pNodeNodeNgrams NodeNodeNgrams
68 { nnng_node1_id = required "node1_id"
69 , nnng_node2_id = required "node2_id"
70 , nnng_ngrams_id = required "ngram_id"
71 , nnng_score = optional "score"
76 queryNodeNodeNgramsTable :: Query NodeNodeNgramsRead
77 queryNodeNodeNgramsTable = queryTable nodeNodeNgramsTable
79 -- | not optimized (get all ngrams without filters)
80 nodeNodeNgrams :: Cmd err [NodeNodeNgrams]
81 nodeNodeNgrams = runOpaQuery queryNodeNodeNgramsTable
83 instance QueryRunnerColumnDefault PGFloat8 (Maybe Double) where
84 queryRunnerColumnDefault = fieldQueryRunnerColumn