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
158
Issues
158
List
Board
Labels
Milestones
Merge Requests
11
Merge Requests
11
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
gargantext
haskell-gargantext
Commits
db05a1d4
Commit
db05a1d4
authored
Apr 29, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DB/FACT] Schema NodeNgramsRepo -> Query (with warnings)
parent
0d5d6390
Pipeline
#838
failed with stage
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
139 additions
and
49 deletions
+139
-49
List.hs
src/Gargantext/Database/Action/Flow/List.hs
+1
-1
Node_NodeNgramsNodeNgrams.hs
...gantext/Database/Query/Table/Node_NodeNgramsNodeNgrams.hs
+78
-0
NodesNgramsRepo.hs
src/Gargantext/Database/Query/Table/NodesNgramsRepo.hs
+57
-0
Node_NodeNgramsNodeNgrams.hs
src/Gargantext/Database/Schema/Node_NodeNgramsNodeNgrams.hs
+3
-29
NodesNgramsRepo.hs
src/Gargantext/Database/Schema/NodesNgramsRepo.hs
+0
-19
No files found.
src/Gargantext/Database/Action/Flow/List.hs
View file @
db05a1d4
...
...
@@ -35,7 +35,7 @@ import Gargantext.Database.Action.Flow.Types
import
Gargantext.Database.Admin.Types.Node
-- (HyperdataDocument(..), NodeType(..), NodeId, UserId, ListId, CorpusId, RootId, MasterCorpusId, MasterUserId)
import
Gargantext.Database.Query.Table.NodeNgrams
(
NodeNgramsPoly
(
..
),
NodeNgramsW
,
listInsertDb
,
getCgramsId
)
import
Gargantext.Database.Schema.Ngrams
-- (insertNgrams, Ngrams(..), NgramsIndexed(..), indexNgrams, NgramsType(..), text2ngrams, ngramsTypeId)
import
Gargantext.Database.
Schema.Node_NodeNgramsNodeNgrams
-- (insert_Node_NodeNgrams_NodeNgrams, Node_NodeNgrams_NodeNgrams(..))
import
Gargantext.Database.
Query.Table.Node_NodeNgramsNodeNgrams
import
Gargantext.Prelude
import
qualified
Data.List
as
List
import
qualified
Data.Map
as
Map
...
...
src/Gargantext/Database/Query/Table/Node_NodeNgramsNodeNgrams.hs
0 → 100644
View file @
db05a1d4
{-|
Module : Gargantext.Database.Schema.Node_NodeNgrams_NodeNgrams
Description :
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
lgrams: listed ngrams
Node_NodeNgrams_NodeNgrams table is used to group ngrams
- first NodeId :: Referential / space node (corpus)
- NodeNgrams where Node is List
- lgrams1_id, lgrams2_id where all lgrams2_id will be added to lgrams1_id
- weight: score the relation
Next Step benchmark:
- recursive queries of postgres
- group with: https://en.wikipedia.org/wiki/Nested_set_model
-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TemplateHaskell #-}
module
Gargantext.Database.Query.Table.Node_NodeNgramsNodeNgrams
(
module
Gargantext
.
Database
.
Schema
.
Node_NodeNgramsNodeNgrams
,
insert_Node_NodeNgrams_NodeNgrams
)
where
import
Control.Lens.TH
(
makeLensesWith
,
abbreviatedFields
)
import
Data.Maybe
(
Maybe
)
import
Gargantext.Database.Schema.Prelude
import
Gargantext.Database.Admin.Utils
(
Cmd
,
runOpaQuery
,
mkCmd
)
import
Gargantext.Database.Admin.Types.Node
(
CorpusId
,
pgNodeId
)
import
Gargantext.Database.Schema.Node_NodeNgramsNodeNgrams
import
Gargantext.Database.Schema.Node
()
import
Gargantext.Prelude
queryNode_NodeNgrams_NodeNgrams_Table
::
Query
Node_NodeNgrams_NodeNgrams_Read
queryNode_NodeNgrams_NodeNgrams_Table
=
queryTable
node_NodeNgrams_NodeNgrams_Table
-- | Select NodeNgramsNgrams
-- TODO not optimized (get all ngrams without filters)
node_Node_NodeNgrams_NodeNgrams
::
Cmd
err
[
Node_NodeNgrams_NodeNgrams
]
node_Node_NodeNgrams_NodeNgrams
=
runOpaQuery
queryNode_NodeNgrams_NodeNgrams_Table
-- TODO: Add option on conflict
insert_Node_NodeNgrams_NodeNgrams
::
[
Node_NodeNgrams_NodeNgrams
]
->
Cmd
err
Int64
insert_Node_NodeNgrams_NodeNgrams
=
insert_Node_NodeNgrams_NodeNgrams_W
.
map
(
\
(
Node_NodeNgrams_NodeNgrams
n
ng1
ng2
maybeWeight
)
->
Node_NodeNgrams_NodeNgrams
(
pgNodeId
n
)
(
pgInt4
<$>
ng1
)
(
pgInt4
ng2
)
(
pgDouble
<$>
maybeWeight
)
)
insert_Node_NodeNgrams_NodeNgrams_W
::
[
Node_NodeNgrams_NodeNgrams_Write
]
->
Cmd
err
Int64
insert_Node_NodeNgrams_NodeNgrams_W
ns
=
mkCmd
$
\
c
->
runInsert_
c
Insert
{
iTable
=
node_NodeNgrams_NodeNgrams_Table
,
iRows
=
ns
,
iReturning
=
rCount
,
iOnConflict
=
(
Just
DoNothing
)
}
src/Gargantext/Database/Query/Table/NodesNgramsRepo.hs
0 → 100644
View file @
db05a1d4
{-|
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 FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TemplateHaskell #-}
module
Gargantext.Database.Query.Table.NodesNgramsRepo
(
module
Gargantext
.
Database
.
Schema
.
NodesNgramsRepo
)
where
import
Gargantext.Database.Schema.Prelude
import
Gargantext.API.Ngrams
(
NgramsStatePatch
,
NgramsTablePatch
)
import
Gargantext.Database.Schema.Ngrams
(
NgramsType
)
import
Gargantext.Database.Admin.Types.Node
(
NodeId
)
import
Gargantext.Database.Schema.NodesNgramsRepo
import
Gargantext.Database.Admin.Utils
(
mkCmd
,
Cmd
,
runOpaQuery
)
import
Gargantext.Prelude
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
->
runInsert_
conn
$
Insert
repoTable
(
toWrite
ns
)
rCount
Nothing
where
toWrite
::
[
NgramsStatePatch
]
->
[
RepoDbWrite
]
toWrite
=
undefined
--ns' = map (\(RepoDbNgrams v ps) -> RepoDbWrite (pgInt4 v) (pgJSONB ps)) ns
src/Gargantext/Database/Schema/Node_NodeNgramsNodeNgrams.hs
View file @
db05a1d4
...
...
@@ -21,6 +21,8 @@ Next Step benchmark:
-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
...
...
@@ -31,7 +33,6 @@ Next Step benchmark:
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module
Gargantext.Database.Schema.Node_NodeNgramsNodeNgrams
where
...
...
@@ -39,8 +40,7 @@ module Gargantext.Database.Schema.Node_NodeNgramsNodeNgrams
import
Control.Lens.TH
(
makeLensesWith
,
abbreviatedFields
)
import
Data.Maybe
(
Maybe
)
import
Gargantext.Database.Schema.Prelude
import
Gargantext.Database.Admin.Utils
(
Cmd
,
runOpaQuery
,
mkCmd
)
import
Gargantext.Database.Admin.Types.Node
(
CorpusId
,
pgNodeId
)
import
Gargantext.Database.Admin.Types.Node
(
CorpusId
)
import
Gargantext.Database.Schema.Node
()
import
Gargantext.Prelude
...
...
@@ -87,35 +87,9 @@ node_NodeNgrams_NodeNgrams_Table =
}
)
queryNode_NodeNgrams_NodeNgrams_Table
::
Query
Node_NodeNgrams_NodeNgrams_Read
queryNode_NodeNgrams_NodeNgrams_Table
=
queryTable
node_NodeNgrams_NodeNgrams_Table
-- | Select NodeNgramsNgrams
-- TODO not optimized (get all ngrams without filters)
node_Node_NodeNgrams_NodeNgrams
::
Cmd
err
[
Node_NodeNgrams_NodeNgrams
]
node_Node_NodeNgrams_NodeNgrams
=
runOpaQuery
queryNode_NodeNgrams_NodeNgrams_Table
instance
QueryRunnerColumnDefault
PGInt4
(
Maybe
Int
)
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
instance
QueryRunnerColumnDefault
PGFloat8
(
Maybe
Double
)
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
-- TODO: Add option on conflict
insert_Node_NodeNgrams_NodeNgrams
::
[
Node_NodeNgrams_NodeNgrams
]
->
Cmd
err
Int64
insert_Node_NodeNgrams_NodeNgrams
=
insert_Node_NodeNgrams_NodeNgrams_W
.
map
(
\
(
Node_NodeNgrams_NodeNgrams
n
ng1
ng2
maybeWeight
)
->
Node_NodeNgrams_NodeNgrams
(
pgNodeId
n
)
(
pgInt4
<$>
ng1
)
(
pgInt4
ng2
)
(
pgDouble
<$>
maybeWeight
)
)
insert_Node_NodeNgrams_NodeNgrams_W
::
[
Node_NodeNgrams_NodeNgrams_Write
]
->
Cmd
err
Int64
insert_Node_NodeNgrams_NodeNgrams_W
ns
=
mkCmd
$
\
c
->
runInsert_
c
Insert
{
iTable
=
node_NodeNgrams_NodeNgrams_Table
,
iRows
=
ns
,
iReturning
=
rCount
,
iOnConflict
=
(
Just
DoNothing
)
}
src/Gargantext/Database/Schema/NodesNgramsRepo.hs
View file @
db05a1d4
...
...
@@ -33,7 +33,6 @@ import Gargantext.Database.Schema.Prelude
import
Gargantext.API.Ngrams
(
NgramsStatePatch
,
NgramsTablePatch
)
import
Gargantext.Database.Schema.Ngrams
(
NgramsType
)
import
Gargantext.Database.Admin.Types.Node
(
NodeId
)
import
Gargantext.Database.Admin.Utils
(
mkCmd
,
Cmd
,
runOpaQuery
)
import
Gargantext.Prelude
...
...
@@ -59,7 +58,6 @@ instance QueryRunnerColumnDefault PGJsonb
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
-- type Re
repoTable
::
Table
RepoDbWrite
RepoDbRead
repoTable
=
Table
"nodes_ngrams_repo"
(
pRepoDbNgrams
RepoDbNgrams
...
...
@@ -68,20 +66,3 @@ repoTable = Table "nodes_ngrams_repo"
}
)
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
->
runInsert_
conn
$
Insert
repoTable
(
toWrite
ns
)
rCount
Nothing
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