]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Query/Table/NodeNodeNgrams2.hs
[FIX] merge dev-phylo and dev
[gargantext.git] / src / Gargantext / Database / Query / Table / NodeNodeNgrams2.hs
1 {-|
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
8 Portability : POSIX
9
10 -}
11
12 {-# OPTIONS_GHC -fno-warn-orphans #-}
13
14 {-# LANGUAGE Arrows #-}
15 {-# LANGUAGE FunctionalDependencies #-}
16 {-# LANGUAGE TemplateHaskell #-}
17
18 module Gargantext.Database.Query.Table.NodeNodeNgrams2
19 ( module Gargantext.Database.Schema.NodeNodeNgrams2
20 , insertNodeNodeNgrams2
21 )
22 where
23
24 import Gargantext.Database.Schema.Prelude
25 import Gargantext.Database.Schema.NodeNodeNgrams2
26 import Gargantext.Database.Admin.Types.Node (pgNodeId)
27 import Gargantext.Database.Prelude (Cmd, mkCmd)
28 import Prelude
29
30
31 _queryNodeNodeNgrams2Table :: Query NodeNodeNgrams2Read
32 _queryNodeNodeNgrams2Table = queryTable nodeNodeNgrams2Table
33
34 -- | Insert utils
35 insertNodeNodeNgrams2 :: [NodeNodeNgrams2] -> Cmd err Int
36 insertNodeNodeNgrams2 = insertNodeNodeNgrams2W
37 . map (\(NodeNodeNgrams2 n1 n2 w) ->
38 NodeNodeNgrams2 (pgNodeId n1)
39 (pgInt4 n2)
40 (pgDouble w)
41 )
42
43 insertNodeNodeNgrams2W :: [NodeNodeNgrams2Write] -> Cmd err Int
44 insertNodeNodeNgrams2W nnnw =
45 mkCmd $ \c -> fromIntegral <$> runInsert_ c insertNothing
46 where
47 insertNothing = Insert { iTable = nodeNodeNgrams2Table
48 , iRows = nnnw
49 , iReturning = rCount
50 , iOnConflict = (Just DoNothing)
51 }