]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Schema/NodesNgramsRepo.hs
[graphql] NUTCTime for gql serialization
[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 FunctionalDependencies #-}
17 {-# LANGUAGE QuasiQuotes #-}
18 {-# LANGUAGE TemplateHaskell #-}
19
20
21 module Gargantext.Database.Schema.NodesNgramsRepo
22 where
23
24 import Data.Map.Strict.Patch (PatchMap)
25
26 import Gargantext.Database.Schema.Prelude
27 import Gargantext.API.Ngrams.Types (NgramsStatePatch, NgramsTablePatch)
28 import Gargantext.Database.Schema.Ngrams (NgramsType)
29 import Gargantext.Database.Admin.Types.Node (NodeId)
30 import Gargantext.Prelude
31
32
33 data RepoDbPoly version patches
34 = RepoDbNgrams { _rdp_version :: !version
35 , _rdp_patches :: !patches
36 } deriving (Show)
37
38 type RepoDbWrite
39 = RepoDbPoly (Column PGInt4)
40 (Column PGJsonb)
41 type RepoDbRead
42 = RepoDbPoly (Column PGInt4)
43 (Column PGJsonb)
44
45 type RepoDbNgrams = RepoDbPoly Int NgramsStatePatch
46 $(makeAdaptorAndInstance "pRepoDbNgrams" ''RepoDbPoly)
47 makeLenses ''RepoDbPoly
48
49 instance DefaultFromField PGJsonb
50 (PatchMap NgramsType
51 (PatchMap NodeId NgramsTablePatch))
52 where
53 defaultFromField = fieldQueryRunnerColumn
54
55 repoTable :: Table RepoDbWrite RepoDbRead
56 repoTable = Table "nodes_ngrams_repo"
57 (pRepoDbNgrams RepoDbNgrams
58 { _rdp_version = requiredTableField "version"
59 , _rdp_patches = requiredTableField "patches"
60 }
61 )
62