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
199
Issues
199
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
b3ad95a1
Commit
b3ad95a1
authored
Jul 25, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Search] Contacts via doc : ok :)
parent
88489429
Pipeline
#980
failed with stage
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
6 deletions
+65
-6
Search.hs
src/Gargantext/Database/Action/Search.hs
+46
-5
Facet.hs
src/Gargantext/Database/Query/Facet.hs
+18
-0
NodeNode.hs
src/Gargantext/Database/Query/Table/NodeNode.hs
+1
-1
No files found.
src/Gargantext/Database/Action/Search.hs
View file @
b3ad95a1
...
...
@@ -36,6 +36,7 @@ import Gargantext.Database.Schema.Node
import
Gargantext.Prelude
import
Gargantext.Text.Terms.Mono.Stem.En
(
stemIt
)
import
Opaleye
hiding
(
Query
,
Order
)
import
Data.Profunctor.Product
(
p4
)
import
qualified
Opaleye
as
O
hiding
(
Order
)
------------------------------------------------------------------------
...
...
@@ -113,17 +114,17 @@ searchInCorpusWithContacts
searchInCorpusWithContacts
cId
aId
q
o
l
_order
=
runOpaQuery
$
limit'
l
$
offset'
o
-- $ orderBy ( o l order
$
selectContactViaDoc
cId
aId
$
orderBy
(
desc
_fp_score
)
$
group
cId
aId
$
intercalate
" | "
$
map
stemIt
q
-- TODO group by
selectContactViaDoc
::
CorpusId
->
AnnuaireId
->
Text
->
O
.
Query
FacetPairedReadNull
->
Select
FacetPairedReadNull
selectContactViaDoc
cId
aId
q
=
proc
()
->
do
(
doc
,
(
corpus_doc
,
(
_contact_doc
,
(
annuaire_contact
,
contact
))))
<-
queryContactViaDoc
-<
()
restrict
-<
(
doc
^.
ns_search
)
@@
(
pgTSQuery
$
unpack
q
)
...
...
@@ -134,7 +135,47 @@ selectContactViaDoc cId aId q = proc () -> do
returnA
-<
FacetPaired
(
contact
^.
node_id
)
(
contact
^.
node_date
)
(
contact
^.
node_hyperdata
)
(
toNullable
$
pgInt4
0
)
(
toNullable
$
pgInt4
1
)
selectContactViaDoc'
::
CorpusId
->
AnnuaireId
->
Text
->
QueryArr
()
(
Column
(
Nullable
PGInt4
)
,
Column
(
Nullable
PGTimestamptz
)
,
Column
(
Nullable
PGJsonb
)
,
Column
(
Nullable
PGInt4
)
)
selectContactViaDoc'
cId
aId
q
=
proc
()
->
do
(
doc
,
(
corpus_doc
,
(
_contact_doc
,
(
annuaire_contact
,
contact
))))
<-
queryContactViaDoc
-<
()
restrict
-<
(
doc
^.
ns_search
)
@@
(
pgTSQuery
$
unpack
q
)
restrict
-<
(
doc
^.
ns_typename
)
.==
(
pgInt4
$
nodeTypeId
NodeDocument
)
restrict
-<
(
corpus_doc
^.
nn_node1_id
)
.==
(
toNullable
$
pgNodeId
cId
)
restrict
-<
(
annuaire_contact
^.
nn_node1_id
)
.==
(
toNullable
$
pgNodeId
aId
)
restrict
-<
(
contact
^.
node_typename
)
.==
(
toNullable
$
pgInt4
$
nodeTypeId
NodeContact
)
returnA
-<
(
contact
^.
node_id
,
contact
^.
node_date
,
contact
^.
node_hyperdata
,
toNullable
$
pgInt4
1
)
group
::
NodeId
->
NodeId
->
Text
->
Select
FacetPairedReadNull
group
cId
aId
q
=
proc
()
->
do
(
a
,
b
,
c
,
d
)
<-
aggregate
(
p4
(
groupBy
,
groupBy
,
groupBy
,
O
.
sum
))
(
selectContactViaDoc'
cId
aId
q
)
-<
()
returnA
-<
FacetPaired
a
b
c
d
queryContactViaDoc
::
O
.
Query
(
NodeSearchRead
,
(
NodeNodeReadNull
...
...
src/Gargantext/Database/Query/Facet.hs
View file @
b3ad95a1
...
...
@@ -30,6 +30,7 @@ module Gargantext.Database.Query.Facet
,
FacetPaired
(
..
)
,
FacetPairedRead
,
FacetPairedReadNull
,
FacetPairedReadNullAgg
,
OrderBy
(
..
)
)
where
...
...
@@ -121,6 +122,8 @@ data FacetPaired id date hyperdata score =
$
(
deriveJSON
(
unPrefix
"_fp_"
)
''
F
acetPaired
)
$
(
makeAdaptorAndInstance
"pFacetPaired"
''
F
acetPaired
)
instance
(
ToSchema
id
,
ToSchema
date
,
ToSchema
hyperdata
...
...
@@ -149,6 +152,21 @@ type FacetPairedReadNull = FacetPaired (Column (Nullable PGInt4) )
(
Column
(
Nullable
PGJsonb
)
)
(
Column
(
Nullable
PGInt4
)
)
type
FacetPairedReadNullAgg
=
FacetPaired
(
Aggregator
(
Column
(
Nullable
PGInt4
)
)
(
Column
(
Nullable
PGInt4
)
)
)
(
Aggregator
(
Column
(
Nullable
PGTimestamptz
))
(
Column
(
Nullable
PGTimestamptz
))
)
(
Aggregator
(
Column
(
Nullable
PGJsonb
)
)
(
Column
(
Nullable
PGJsonb
)
)
)
(
Aggregator
(
Column
(
Nullable
PGInt4
)
)
(
Column
(
Nullable
PGInt4
)
)
)
-- | JSON instance
...
...
src/Gargantext/Database/Query/Table/NodeNode.hs
View file @
b3ad95a1
...
...
@@ -97,7 +97,7 @@ getNodeNodeWith pId _ maybeNodeType = runOpaQuery query
------------------------------------------------------------------------
insertNodeNode
::
[
NodeNode
]
->
Cmd
err
Int
insertNodeNode
ns
=
mkCmd
$
\
conn
->
fromIntegral
<$>
(
runInsert_
conn
$
Insert
nodeNodeTable
ns'
rCount
Nothing
)
$
Insert
nodeNodeTable
ns'
rCount
(
Just
DoNothing
)
)
where
ns'
::
[
NodeNodeWrite
]
ns'
=
map
(
\
(
NodeNode
n1
n2
x
y
)
...
...
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