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 FlexibleContexts #-}
16 {-# LANGUAGE FlexibleInstances #-}
17 {-# LANGUAGE FunctionalDependencies #-}
18 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
19 {-# LANGUAGE MultiParamTypeClasses #-}
20 {-# LANGUAGE NoImplicitPrelude #-}
21 {-# LANGUAGE OverloadedStrings #-}
22 {-# LANGUAGE QuasiQuotes #-}
23 {-# LANGUAGE RankNTypes #-}
24 {-# LANGUAGE TemplateHaskell #-}
26 module Gargantext.Database.Query.Table.NodesNgramsRepo
27 ( module Gargantext.Database.Schema.NodesNgramsRepo
31 import Gargantext.Database.Schema.Prelude
32 import Gargantext.API.Ngrams (NgramsStatePatch)
33 import Gargantext.Database.Schema.NodesNgramsRepo
34 import Gargantext.Database.Admin.Utils (mkCmd, Cmd, runOpaQuery)
35 import Gargantext.Prelude
38 selectPatches :: Query RepoDbRead
39 selectPatches = proc () -> do
40 repos <- queryTable repoTable -< ()
43 _selectRepo :: Cmd err [RepoDbNgrams]
44 _selectRepo = runOpaQuery selectPatches
46 _insertRepos :: [NgramsStatePatch] -> Cmd err Int64
47 _insertRepos ns = mkCmd $ \conn -> runInsert_ conn $ Insert repoTable (toWrite ns) rCount Nothing
49 toWrite :: [NgramsStatePatch] -> [RepoDbWrite]
51 --ns' = map (\(RepoDbNgrams v ps) -> RepoDbWrite (pgInt4 v) (pgJSONB ps)) ns