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 {-# OPTIONS_GHC -fno-warn-orphans #-}
14 {-# LANGUAGE Arrows #-}
15 {-# LANGUAGE FlexibleContexts #-}
16 {-# LANGUAGE FlexibleInstances #-}
17 {-# LANGUAGE FunctionalDependencies #-}
18 {-# LANGUAGE MultiParamTypeClasses #-}
19 {-# LANGUAGE NoImplicitPrelude #-}
20 {-# LANGUAGE RankNTypes #-}
21 {-# LANGUAGE TemplateHaskell #-}
23 module Gargantext.Database.Query.Table.NodeNodeNgrams
24 ( module Gargantext.Database.Schema.NodeNodeNgrams
25 , queryNodeNodeNgramsTable
26 , insertNodeNodeNgrams
30 import Gargantext.Database.Admin.Types.Node (pgNodeId)
31 import Gargantext.Database.Admin.Utils (Cmd, mkCmd)
32 import Gargantext.Database.Schema.Ngrams (pgNgramsTypeId)
33 import Gargantext.Database.Schema.NodeNodeNgrams
34 import Gargantext.Database.Schema.Prelude
38 queryNodeNodeNgramsTable :: Query NodeNodeNgramsRead
39 queryNodeNodeNgramsTable = queryTable nodeNodeNgramsTable
42 insertNodeNodeNgrams :: [NodeNodeNgrams] -> Cmd err Int
43 insertNodeNodeNgrams = insertNodeNodeNgramsW
44 . map (\(NodeNodeNgrams n1 n2 ng nt w) ->
45 NodeNodeNgrams (pgNodeId n1)
52 insertNodeNodeNgramsW :: [NodeNodeNgramsWrite] -> Cmd err Int
53 insertNodeNodeNgramsW nnnw =
54 mkCmd $ \c -> fromIntegral <$> runInsert_ c insertNothing
56 insertNothing = (Insert { iTable = nodeNodeNgramsTable
59 , iOnConflict = (Just DoNothing)