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
23 import Gargantext.Database.Schema.Prelude
24 import Gargantext.API.Ngrams (NgramsStatePatch)
25 import Gargantext.Database.Schema.NodesNgramsRepo
26 import Gargantext.Database.Prelude (mkCmd, Cmd, runOpaQuery)
27 import Gargantext.Prelude
30 selectPatches :: Query RepoDbRead
31 selectPatches = proc () -> do
32 repos <- selectTable repoTable -< ()
35 _selectRepo :: Cmd err [RepoDbNgrams]
36 _selectRepo = runOpaQuery selectPatches
38 _insertRepos :: [NgramsStatePatch] -> Cmd err Int64
39 _insertRepos ns = mkCmd $ \conn -> runInsert_ conn $ Insert repoTable (toWrite ns) rCount Nothing
41 toWrite :: [NgramsStatePatch] -> [RepoDbWrite]
43 --ns' = map (\(RepoDbNgrams v ps) -> RepoDbWrite (sqlInt4 v) (pgJSONB ps)) ns