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
10
Merge Requests
10
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
9f3feb43
Commit
9f3feb43
authored
Jan 30, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] Enabling again: Pairs CorpusId AnnuaireId (unoptimized for now).
parent
47f77b50
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
26 deletions
+41
-26
API.hs
src/Gargantext/API.hs
+3
-2
Node.hs
src/Gargantext/API/Node.hs
+2
-2
Table.hs
src/Gargantext/API/Table.hs
+3
-3
Facet.hs
src/Gargantext/Database/Facet.hs
+30
-17
Pairing.hs
src/Gargantext/Database/Flow/Pairing.hs
+3
-2
No files found.
src/Gargantext/API.hs
View file @
9f3feb43
...
...
@@ -15,10 +15,11 @@ This API is indeed typed in order to be able to derive both the server
and the client sides.
The Garg-API-Monad enables:
- Features
- Security (WIP)
- Features (WIP)
- Database connection (long term)
- In Memory stack management (short term)
- Logs
- Logs
(WIP)
Thanks to @yannEsposito (at the start) and @np (after).
...
...
src/Gargantext/API/Node.hs
View file @
9f3feb43
...
...
@@ -128,7 +128,7 @@ type NodeAPI a = Get '[JSON] (Node a)
-- TODO gather it
:<|>
"table"
:>
TableApi
:<|>
"ngrams"
:>
TableNgramsApi
--
:<|> "pairing" :> PairingApi
:<|>
"pairing"
:>
PairingApi
:<|>
"category"
:>
CatApi
:<|>
"search"
:>
SearchDocsAPI
...
...
@@ -188,7 +188,7 @@ nodeAPI p uId id = withAccess (Proxy :: Proxy (NodeAPI a)) Proxy uId (PathNode i
-- TODO gather it
:<|>
tableApi
id
:<|>
apiNgramsTableCorpus
id
--
:<|> getPairing id
:<|>
getPairing
id
-- :<|> getTableNgramsDoc id
:<|>
catApi
id
...
...
src/Gargantext/API/Table.hs
View file @
9f3feb43
...
...
@@ -46,7 +46,7 @@ import GHC.Generics (Generic)
import
Gargantext.API.Ngrams
(
TabType
(
..
))
import
Gargantext.Core.Types
(
Offset
,
Limit
,
TableResult
(
..
))
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
unPrefixSwagger
)
import
Gargantext.Database.Facet
(
FacetDoc
,
runViewDocuments
,
OrderBy
(
..
))
import
Gargantext.Database.Facet
(
FacetDoc
,
runViewDocuments
,
OrderBy
(
..
)
,
runViewAuthorsDoc
)
import
Gargantext.Database.Learn
(
FavOrTrash
(
..
),
moreLike
)
import
Gargantext.Database.TextSearch
import
Gargantext.Database.Types.Node
...
...
@@ -121,7 +121,7 @@ getTable' cId ft o l order =
(
Just
MoreTrash
)
->
moreLike
cId
o
l
order
IsTrash
x
->
panic
$
"not implemented in getTable: "
<>
(
cs
$
show
x
)
{-
--
{-
getPairing
::
ContactId
->
Maybe
TabType
->
Maybe
Offset
->
Maybe
Limit
->
Maybe
OrderBy
->
Cmd
err
[
FacetDoc
]
...
...
@@ -131,4 +131,4 @@ getPairing cId ft o l order =
(
Just
Trash
)
->
runViewAuthorsDoc
cId
True
o
l
order
_
->
panic
$
"not implemented: get Pairing"
<>
(
cs
$
show
ft
)
-}
-
-
}
src/Gargantext/Database/Facet.hs
View file @
9f3feb43
...
...
@@ -26,8 +26,8 @@ Portability : POSIX
{-# LANGUAGE TypeFamilies #-}
------------------------------------------------------------------------
module
Gargantext.Database.Facet
(
--
runViewAuthorsDoc
runViewDocuments
(
runViewAuthorsDoc
,
runViewDocuments
,
filterWith
,
Pair
(
..
)
...
...
@@ -57,9 +57,13 @@ import Gargantext.Core.Types
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
unPrefixSwagger
)
import
Gargantext.Database.Config
(
nodeTypeId
)
import
Gargantext.Database.Schema.Node
import
Gargantext.Database.Schema.Ngrams
import
Gargantext.Database.Schema.NodeNode
import
Gargantext.Database.Schema.NodeNodeNgrams
-- import Gargantext.Database.Schema.NodeNodeNgrams2
import
Gargantext.Database.Utils
import
Gargantext.Database.Queries.Filter
import
Gargantext.Database.Queries.Join
(
leftJoin5
)
import
Opaleye
import
Prelude
hiding
(
null
,
id
,
map
,
sum
,
not
,
read
)
import
Servant.API
...
...
@@ -208,7 +212,7 @@ instance Arbitrary OrderBy
-- TODO-SECURITY check
{-
--
{-
runViewAuthorsDoc
::
ContactId
->
IsTrash
->
Maybe
Offset
->
Maybe
Limit
->
Maybe
OrderBy
->
Cmd
err
[
FacetDoc
]
runViewAuthorsDoc
cId
t
o
l
order
=
runOpaQuery
$
filterWith
o
l
order
$
viewAuthorsDoc
cId
t
ntId
where
...
...
@@ -227,26 +231,31 @@ viewAuthorsDoc cId _ nt = proc () -> do
restrict
-<
_node_id
contact
.==
(
toNullable
$
pgNodeId
cId
)
restrict
-<
_node_typename
doc
.==
(
pgInt4
$
nodeTypeId
nt
)
returnA -< FacetDoc (_node_id doc) (_node_date doc) (_node_name doc) (_node_hyperdata doc) (toNullable $ pgInt4 1) (toNullable $ pgDouble 1)
returnA
-<
FacetDoc
(
_node_id
doc
)
(
_node_date
doc
)
(
_node_name
doc
)
(
_node_hyperdata
doc
)
(
toNullable
$
pgInt4
1
)
(
toNullable
$
pgDouble
1
)
queryAuthorsDoc :: Query (NodeRead, (NodeN
gramReadNull, (NgramsReadNull, (NodeNgram
ReadNull, NodeReadNull))))
queryAuthorsDoc = leftJoin5 queryNodeTable queryNodeN
gramTable queryNgramsTable queryNodeNgram
Table queryNodeTable cond12 cond23 cond34 cond45
queryAuthorsDoc
::
Query
(
NodeRead
,
(
NodeN
odeNgramsReadNull
,
(
NgramsReadNull
,
(
NodeNodeNgrams
ReadNull
,
NodeReadNull
))))
queryAuthorsDoc
=
leftJoin5
queryNodeTable
queryNodeN
odeNgramsTable
queryNgramsTable
queryNodeNodeNgrams
Table
queryNodeTable
cond12
cond23
cond34
cond45
where
cond12 :: (NodeN
gram
Read, NodeRead) -> Column PGBool
cond12
::
(
NodeN
odeNgrams
Read
,
NodeRead
)
->
Column
PGBool
cond12
(
nodeNgram
,
doc
)
=
_node_id
doc
.==
nng_node
_id nodeNgram
.==
_nnng_node1
_id
nodeNgram
cond23 :: (NgramsRead, (NodeN
gram
Read, NodeReadNull)) -> Column PGBool
cond23
::
(
NgramsRead
,
(
NodeN
odeNgrams
Read
,
NodeReadNull
))
->
Column
PGBool
cond23
(
ngrams
,
(
nodeNgram
,
_
))
=
ngrams
^.
ngrams_id
.== nng_ngrams_id nodeNgram
.==
_n
nng_ngrams_id
nodeNgram
cond34 :: (NodeN
gramRead, (NgramsRead, (NodeNgram
ReadNull, NodeReadNull))) -> Column PGBool
cond34 (nodeNgram2, (ngrams, (_,_)))= ngrams^.ngrams_id .== nng_ngrams_id nodeNgram2
cond34
::
(
NodeN
odeNgramsRead
,
(
NgramsRead
,
(
NodeNodeNgrams
ReadNull
,
NodeReadNull
)))
->
Column
PGBool
cond34
(
nodeNgram2
,
(
ngrams
,
(
_
,
_
)))
=
ngrams
^.
ngrams_id
.==
_n
nng_ngrams_id
nodeNgram2
cond45 :: (NodeRead, (NodeN
gramRead, (NgramsReadNull, (NodeNgram
ReadNull, NodeReadNull)))) -> Column PGBool
cond45 (contact, (nodeNgram2, (_, (_,_)))) = _node_id contact .==
nng_node
_id nodeNgram2
cond45
::
(
NodeRead
,
(
NodeN
odeNgramsRead
,
(
NgramsReadNull
,
(
NodeNodeNgrams
ReadNull
,
NodeReadNull
))))
->
Column
PGBool
cond45
(
contact
,
(
nodeNgram2
,
(
_
,
(
_
,
_
))))
=
_node_id
contact
.==
_nnng_node1
_id
nodeNgram2
-}
-
-
}
------------------------------------------------------------------------
-- TODO-SECURITY check
...
...
@@ -265,8 +274,12 @@ viewDocuments cId t ntId = proc () -> do
restrict
-<
n
^.
node_typename
.==
(
pgInt4
ntId
)
restrict
-<
if
t
then
nn
^.
nn_category
.==
(
pgInt4
0
)
else
nn
^.
nn_category
.>=
(
pgInt4
1
)
returnA
-<
FacetDoc
(
_node_id
n
)
(
_node_date
n
)
(
_node_name
n
)
(
_node_hyperdata
n
)
(
toNullable
$
nn
^.
nn_category
)
(
toNullable
$
nn
^.
nn_score
)
returnA
-<
FacetDoc
(
_node_id
n
)
(
_node_date
n
)
(
_node_name
n
)
(
_node_hyperdata
n
)
(
toNullable
$
nn
^.
nn_category
)
(
toNullable
$
nn
^.
nn_score
)
------------------------------------------------------------------------
filterWith
::
(
PGOrd
date
,
PGOrd
title
,
PGOrd
score
,
hyperdata
~
Column
SqlJsonb
)
=>
...
...
src/Gargantext/Database/Flow/Pairing.hs
View file @
9f3feb43
...
...
@@ -52,8 +52,8 @@ pairing' = undefined
-}
-- | TODO : add paring policy as parameter
pairing
::
AnnuaireId
->
CorpusId
pairing
::
AnnuaireId
-- (AnnuaireId, ListId) -- Pair (Either CorpusId AnnuaireId) ListId
->
CorpusId
-- (CorpusId, ListId) -- Pair (Either CorpusId AnnuaireId) ListId
->
ListId
->
Cmd
err
Int
pairing
aId
cId
lId
=
do
...
...
@@ -120,6 +120,7 @@ getNgramsTindexed corpusId ngramsType' = fromList
where
selectQuery
=
[
sql
|
SELECT n.id,n.terms,n.n from ngrams n
JOIN node_node_ngrams occ ON occ.ngrams_id = n.id
-- JOIN node_node_ngrams2 occ ON occ.ngrams_id = n.id
JOIN nodes_nodes nn ON nn.node2_id = occ.node2_id
WHERE nn.node1_id = ?
...
...
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