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
195
Issues
195
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
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
b6eedd61
Commit
b6eedd61
authored
Jul 21, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Utils] function to list all Annuaires paired with a corpus
parent
be5d6421
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
15 deletions
+76
-15
Pairing.hs
src/Gargantext/Database/Action/Flow/Pairing.hs
+27
-4
Search.hs
src/Gargantext/Database/Action/Search.hs
+0
-2
Join.hs
src/Gargantext/Database/Query/Join.hs
+24
-9
Prelude.hs
src/Gargantext/Database/Query/Prelude.hs
+25
-0
No files found.
src/Gargantext/Database/Action/Flow/Pairing.hs
View file @
b6eedd61
...
...
@@ -9,8 +9,8 @@ Portability : POSIX
-}
{-# LANGUAGE QuasiQuotes
#-}
-- {-# LANGUAGE Arrows
#-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE Arrows
#-}
module
Gargantext.Database.Action.Flow.Pairing
-- (pairing)
...
...
@@ -26,9 +26,11 @@ import Gargantext.Core.Types (TableResult(..), Term)
import
Gargantext.Database
import
Gargantext.Database.Admin.Types.Hyperdata
-- (HyperdataContact(..))
import
Gargantext.Database.Admin.Types.Node
-- (AnnuaireId, CorpusId, ListId, DocId, ContactId, NodeId)
import
Gargantext.Database.Prelude
(
Cmd
,
runPGSQuery
)
import
Gargantext.Database.Prelude
(
Cmd
,
runPGSQuery
,
runOpaQuery
)
import
Gargantext.Database.Query.Prelude
(
leftJoin2
,
returnA
,
queryNodeNodeTable
)
import
Gargantext.Database.Query.Table.Node.Children
(
getAllContacts
)
import
Gargantext.Database.Schema.Ngrams
-- (NgramsType(..))
import
Gargantext.Database.Admin.Config
(
nodeTypeId
)
import
Gargantext.Database.Schema.Node
import
Gargantext.Prelude
hiding
(
sum
)
import
Safe
(
lastMay
)
...
...
@@ -36,6 +38,28 @@ import qualified Data.List as List
import
qualified
Data.Map
as
Map
import
qualified
Data.Text
as
DT
import
qualified
Data.Set
as
Set
import
Opaleye
-- | isPairedWith
-- All NodeAnnuaire paired with a Corpus of NodeId nId:
-- isPairedWith NodeAnnuaire corpusId
isPairedWith
::
NodeType
->
NodeId
->
Cmd
err
[
NodeId
]
isPairedWith
nt
nId
=
runOpaQuery
(
selectQuery
nt
nId
)
where
selectQuery
::
NodeType
->
NodeId
->
Query
(
Column
PGInt4
)
selectQuery
nt'
nId'
=
proc
()
->
do
(
node
,
node_node
)
<-
queryJoin
-<
()
restrict
-<
(
node
^.
node_typename
)
.==
(
pgInt4
$
nodeTypeId
nt'
)
restrict
-<
(
node_node
^.
nn_node1_id
)
.==
(
toNullable
$
pgNodeId
nId'
)
returnA
-<
node
^.
node_id
queryJoin
::
Query
(
NodeRead
,
NodeNodeReadNull
)
queryJoin
=
leftJoin2
queryNodeTable
queryNodeNodeTable
cond
where
cond
(
node
,
node_node
)
=
node
^.
node_id
.==
node_node
^.
nn_node2_id
-----------------------------------------------------------------------
...
...
@@ -170,4 +194,3 @@ selectNgramsDocId corpusId' listId' ngramsType' =
AND nnng.ngrams_type = ?
;
|]
src/Gargantext/Database/Action/Search.hs
View file @
b6eedd61
...
...
@@ -136,8 +136,6 @@ selectContactViaDoc cId aId q = proc () -> do
(
contact
^.
node_hyperdata
)
(
toNullable
$
pgInt4
0
)
queryContactViaDoc
::
O
.
Query
(
NodeSearchRead
,
(
NodeNodeReadNull
,
(
NodeNodeReadNull
...
...
src/Gargantext/Database/Query/Join.hs
View file @
b6eedd61
...
...
@@ -22,7 +22,15 @@ Multiple Join functions with Opaleye.
------------------------------------------------------------------------
module
Gargantext.Database.Query.Join
module
Gargantext.Database.Query.Join
(
leftJoin2
,
leftJoin3
,
leftJoin4
,
leftJoin5
,
leftJoin6
,
leftJoin7
,
leftJoin8
,
leftJoin9
)
where
import
Control.Applicative
((
<*>
))
...
...
@@ -33,17 +41,24 @@ import Opaleye
import
Opaleye.Internal.Join
(
NullMaker
(
..
))
import
qualified
Opaleye.Internal.Unpackspec
()
--leftJoin3 :: Query columnsL1 -> Query columnsR -> Query columnsL
-- -> ((columnsL1, columnsR) -> Column PGBool)
-- -> ((columnsL, (columnsL1, nullableColumnsR1)) -> Column PGBool)
-- -> Query (columnsL, nullableColumnsR)
--leftJoin3 q1 q2 q3 cond12 cond23 = leftJoin q3 (leftJoin q1 q2 cond12) cond23
join3
::
Query
columnsA
->
Query
columnsB
->
Query
columnsC
------------------------------------------------------------------------
leftJoin2
::
(
Default
Unpackspec
fieldsL
fieldsL
,
Default
Unpackspec
fieldsR
fieldsR
,
Default
NullMaker
fieldsR
nullableFieldsR
)
=>
Select
fieldsL
->
Select
fieldsR
->
((
fieldsL
,
fieldsR
)
->
Column
PGBool
)
->
Select
(
fieldsL
,
nullableFieldsR
)
leftJoin2
=
leftJoin
------------------------------------------------------------------------
-- | LeftJoin3 in two ways to write it
_leftJoin3
::
Query
columnsA
->
Query
columnsB
->
Query
columnsC
->
((
columnsA
,
columnsB
,
columnsC
)
->
Column
PGBool
)
->
Query
(
columnsA
,
columnsB
,
columnsC
)
join3
q1
q2
q3
cond
=
((,,)
<$>
q1
<*>
q2
<*>
q3
)
>>>
keepWhen
cond
_leftJoin3
q1
q2
q3
cond
=
((,,)
<$>
q1
<*>
q2
<*>
q3
)
>>>
keepWhen
cond
------------------------------------------------------------------------
leftJoin3
::
(
Default
Unpackspec
fieldsL1
fieldsL1
,
Default
Unpackspec
fieldsL2
fieldsL2
,
...
...
src/Gargantext/Database/Query/Prelude.hs
0 → 100644
View file @
b6eedd61
{-|
Module : Gargantext.Database.Query.Prelude
Description :
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
------------------------------------------------------------------------
module
Gargantext.Database.Query.Prelude
(
module
Gargantext
.
Database
.
Query
.
Join
,
module
Gargantext
.
Database
.
Query
.
Table
.
Node
,
module
Gargantext
.
Database
.
Query
.
Table
.
NodeNode
,
module
Control
.
Arrow
)
where
import
Control.Arrow
(
returnA
)
import
Gargantext.Database.Query.Join
import
Gargantext.Database.Query.Table.Node
import
Gargantext.Database.Query.Table.NodeNode
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