]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Query/Table/NodesNgramsRepo.hs
[DB/Errors] clean error messages and structure
[gargantext.git] / src / Gargantext / Database / Query / Table / NodesNgramsRepo.hs
1 {-|
2 Module : Gargantext.Database.Schema.NodesNgramsRepo
3 Description :
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 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 #-}
25
26 module Gargantext.Database.Query.Table.NodesNgramsRepo
27 ( module Gargantext.Database.Schema.NodesNgramsRepo
28 )
29 where
30
31 import Gargantext.Database.Schema.Prelude
32 import Gargantext.API.Ngrams (NgramsStatePatch)
33 import Gargantext.Database.Schema.NodesNgramsRepo
34 import Gargantext.Database.Prelude (mkCmd, Cmd, runOpaQuery)
35 import Gargantext.Prelude
36
37
38 selectPatches :: Query RepoDbRead
39 selectPatches = proc () -> do
40 repos <- queryTable repoTable -< ()
41 returnA -< repos
42
43 _selectRepo :: Cmd err [RepoDbNgrams]
44 _selectRepo = runOpaQuery selectPatches
45
46 _insertRepos :: [NgramsStatePatch] -> Cmd err Int64
47 _insertRepos ns = mkCmd $ \conn -> runInsert_ conn $ Insert repoTable (toWrite ns) rCount Nothing
48 where
49 toWrite :: [NgramsStatePatch] -> [RepoDbWrite]
50 toWrite = undefined
51 --ns' = map (\(RepoDbNgrams v ps) -> RepoDbWrite (pgInt4 v) (pgJSONB ps)) ns
52