]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Schema/NodesNgramsRepo.hs
[DB/REFACT] Node actions (WIP).
[gargantext.git] / src / Gargantext / Database / Schema / NodesNgramsRepo.hs
1 {-|
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
8 Portability : POSIX
9
10
11 -}
12
13 {-# OPTIONS_GHC -fno-warn-orphans #-}
14
15 {-# LANGUAGE Arrows #-}
16 {-# LANGUAGE FlexibleContexts #-}
17 {-# LANGUAGE FlexibleInstances #-}
18 {-# LANGUAGE FunctionalDependencies #-}
19 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
20 {-# LANGUAGE MultiParamTypeClasses #-}
21 {-# LANGUAGE NoImplicitPrelude #-}
22 {-# LANGUAGE OverloadedStrings #-}
23 {-# LANGUAGE QuasiQuotes #-}
24 {-# LANGUAGE RankNTypes #-}
25 {-# LANGUAGE TemplateHaskell #-}
26
27
28 module Gargantext.Database.Schema.NodesNgramsRepo
29 where
30
31 import Data.Map.Strict.Patch (PatchMap)
32 import Gargantext.Database.Schema.Prelude
33 import Gargantext.API.Ngrams (NgramsStatePatch, NgramsTablePatch)
34 import Gargantext.Database.Schema.Ngrams (NgramsType)
35 import Gargantext.Database.Admin.Types.Node (NodeId)
36 import Gargantext.Prelude
37
38
39 data RepoDbPoly version patches
40 = RepoDbNgrams { _rdp_version :: !version
41 , _rdp_patches :: !patches
42 } deriving (Show)
43
44 type RepoDbWrite
45 = RepoDbPoly (Column PGInt4)
46 (Column PGJsonb)
47 type RepoDbRead
48 = RepoDbPoly (Column PGInt4)
49 (Column PGJsonb)
50
51 type RepoDbNgrams = RepoDbPoly Int NgramsStatePatch
52 $(makeAdaptorAndInstance "pRepoDbNgrams" ''RepoDbPoly)
53 makeLenses ''RepoDbPoly
54
55 instance QueryRunnerColumnDefault PGJsonb
56 (PatchMap NgramsType
57 (PatchMap NodeId NgramsTablePatch))
58 where
59 queryRunnerColumnDefault = fieldQueryRunnerColumn
60
61 repoTable :: Table RepoDbWrite RepoDbRead
62 repoTable = Table "nodes_ngrams_repo"
63 (pRepoDbNgrams RepoDbNgrams
64 { _rdp_version = required "version"
65 , _rdp_patches = required "patches"
66 }
67 )
68