2 Module : Gargantext.Database.Schema.NodesNgramsRepo
3 Description : NodeNgram for Ngram indexation or Lists
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
13 {-# OPTIONS_GHC -fno-warn-orphans #-}
15 {-# LANGUAGE Arrows #-}
16 {-# LANGUAGE FunctionalDependencies #-}
17 {-# LANGUAGE QuasiQuotes #-}
18 {-# LANGUAGE TemplateHaskell #-}
21 module Gargantext.Database.Schema.NodesNgramsRepo
25 import Data.Map.Strict.Patch (PatchMap)
27 import Gargantext.Database.Schema.Prelude
28 import Gargantext.API.Ngrams.Types (NgramsTablePatch)
29 import Gargantext.Database.Schema.Ngrams (NgramsType)
30 import Gargantext.Database.Admin.Types.Node (NodeId)
31 import Gargantext.Prelude
34 data RepoDbPoly version patches
35 = RepoDbNgrams { _rdp_version :: !version
36 , _rdp_patches :: !patches
40 = RepoDbPoly (Column SqlInt4)
43 = RepoDbPoly (Column SqlInt4)
46 type RepoDbNgrams = RepoDbPoly Int NgramsStatePatch
47 $(makeAdaptorAndInstance "pRepoDbNgrams" ''RepoDbPoly)
48 makeLenses ''RepoDbPoly
50 instance DefaultFromField SqlJsonb
52 (PatchMap NodeId NgramsTablePatch))
54 defaultFromField = fromPGSFromField
56 repoTable :: Table RepoDbWrite RepoDbRead
57 repoTable = Table "nodes_ngrams_repo"
58 (pRepoDbNgrams RepoDbNgrams
59 { _rdp_version = requiredTableField "version"
60 , _rdp_patches = requiredTableField "patches"