2 Module : Gargantext.Database.Schema.NodesNgramsRepo
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 FunctionalDependencies #-}
16 {-# LANGUAGE QuasiQuotes #-}
17 {-# LANGUAGE TemplateHaskell #-}
19 module Gargantext.Database.Query.Table.NodesNgramsRepo
20 ( module Gargantext.Database.Schema.NodesNgramsRepo
24 import Gargantext.Database.Schema.Prelude
25 import Gargantext.API.Ngrams (NgramsStatePatch)
26 import Gargantext.Database.Schema.NodesNgramsRepo
27 import Gargantext.Database.Prelude (mkCmd, Cmd, runOpaQuery)
28 import Gargantext.Prelude
31 selectPatches :: Query RepoDbRead
32 selectPatches = proc () -> do
33 repos <- queryTable repoTable -< ()
36 _selectRepo :: Cmd err [RepoDbNgrams]
37 _selectRepo = runOpaQuery selectPatches
39 _insertRepos :: [NgramsStatePatch] -> Cmd err Int64
40 _insertRepos ns = mkCmd $ \conn -> runInsert_ conn $ Insert repoTable (toWrite ns) rCount Nothing
42 toWrite :: [NgramsStatePatch] -> [RepoDbWrite]
44 --ns' = map (\(RepoDbNgrams v ps) -> RepoDbWrite (pgInt4 v) (pgJSONB ps)) ns