Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Christian Merten
haskell-gargantext
Commits
5dc4c39f
Commit
5dc4c39f
authored
Feb 16, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NGRAMS REPO] Database feature (for future).
parent
1f9f3f09
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
0 deletions
+88
-0
NodesNgramsRepo.hs
src/Gargantext/Database/Schema/NodesNgramsRepo.hs
+88
-0
No files found.
src/Gargantext/Database/Schema/NodesNgramsRepo.hs
0 → 100644
View file @
5dc4c39f
{-|
Module : Gargantext.Database.Schema.NodesNgramsRepo
Description : NodeNgram for Ngram indexation or Lists
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TemplateHaskell #-}
module
Gargantext.Database.Schema.NodesNgramsRepo
where
import
Control.Arrow
(
returnA
)
import
Control.Lens.TH
(
makeLenses
)
import
Data.Map.Strict.Patch
(
PatchMap
)
import
Data.Profunctor.Product.TH
(
makeAdaptorAndInstance
)
import
Gargantext.API.Ngrams
(
NgramsStatePatch
,
NgramsTablePatch
)
import
Gargantext.Database.Schema.Ngrams
(
NgramsType
)
import
Gargantext.Database.Types.Node
(
NodeId
)
import
Gargantext.Database.Utils
(
mkCmd
,
Cmd
,
runOpaQuery
)
import
Gargantext.Prelude
import
Opaleye
data
RepoDbPoly
version
patches
=
RepoDbNgrams
{
_rdp_version
::
version
,
_rdp_patches
::
patches
}
deriving
(
Show
)
type
RepoDbWrite
=
RepoDbPoly
(
Column
PGInt4
)
(
Column
PGJsonb
)
type
RepoDbRead
=
RepoDbPoly
(
Column
PGInt4
)
(
Column
PGJsonb
)
type
RepoDbNgrams
=
RepoDbPoly
Int
NgramsStatePatch
$
(
makeAdaptorAndInstance
"pRepoDbNgrams"
''
R
epoDbPoly
)
makeLenses
''
R
epoDbPoly
instance
QueryRunnerColumnDefault
PGJsonb
(
PatchMap
NgramsType
(
PatchMap
NodeId
NgramsTablePatch
))
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
-- type Re
repoTable
::
Table
RepoDbWrite
RepoDbRead
repoTable
=
Table
"nodes_ngrams_repo"
(
pRepoDbNgrams
RepoDbNgrams
{
_rdp_version
=
required
"version"
,
_rdp_patches
=
required
"patches"
}
)
selectRepo
::
Cmd
err
[
RepoDbNgrams
]
selectRepo
=
runOpaQuery
selectPatches
selectPatches
::
Query
RepoDbRead
selectPatches
=
proc
()
->
do
repos
<-
queryTable
repoTable
-<
()
returnA
-<
repos
insertRepos
::
[
NgramsStatePatch
]
->
Cmd
err
Int64
insertRepos
ns
=
mkCmd
$
\
conn
->
runInsertMany
conn
repoTable
(
toWrite
ns
)
where
toWrite
::
[
NgramsStatePatch
]
->
[
RepoDbWrite
]
toWrite
=
undefined
--ns' = map (\(RepoDbNgrams v ps) -> RepoDbWrite (pgInt4 v) (pgJSONB ps)) ns
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment