Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
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
Przemyslaw Kaminski
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
Changes
3
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
...
@@ -36,6 +36,7 @@ import Gargantext.Database.Schema.Node
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Text.Terms.Mono.Stem.En
(
stemIt
)
import
Gargantext.Text.Terms.Mono.Stem.En
(
stemIt
)
import
Opaleye
hiding
(
Query
,
Order
)
import
Opaleye
hiding
(
Query
,
Order
)
import
Data.Profunctor.Product
(
p4
)
import
qualified
Opaleye
as
O
hiding
(
Order
)
import
qualified
Opaleye
as
O
hiding
(
Order
)
------------------------------------------------------------------------
------------------------------------------------------------------------
...
@@ -113,17 +114,17 @@ searchInCorpusWithContacts
...
@@ -113,17 +114,17 @@ searchInCorpusWithContacts
searchInCorpusWithContacts
cId
aId
q
o
l
_order
=
searchInCorpusWithContacts
cId
aId
q
o
l
_order
=
runOpaQuery
$
limit'
l
runOpaQuery
$
limit'
l
$
offset'
o
$
offset'
o
-- $ orderBy ( o l order
$
orderBy
(
desc
_fp_score
)
$
selectContactViaDoc
cId
aId
$
group
cId
aId
$
intercalate
" | "
$
intercalate
" | "
$
map
stemIt
q
$
map
stemIt
q
-- TODO group by
selectContactViaDoc
selectContactViaDoc
::
CorpusId
::
CorpusId
->
AnnuaireId
->
AnnuaireId
->
Text
->
Text
->
O
.
Query
FacetPairedReadNull
->
Select
FacetPairedReadNull
selectContactViaDoc
cId
aId
q
=
proc
()
->
do
selectContactViaDoc
cId
aId
q
=
proc
()
->
do
(
doc
,
(
corpus_doc
,
(
_contact_doc
,
(
annuaire_contact
,
contact
))))
<-
queryContactViaDoc
-<
()
(
doc
,
(
corpus_doc
,
(
_contact_doc
,
(
annuaire_contact
,
contact
))))
<-
queryContactViaDoc
-<
()
restrict
-<
(
doc
^.
ns_search
)
@@
(
pgTSQuery
$
unpack
q
)
restrict
-<
(
doc
^.
ns_search
)
@@
(
pgTSQuery
$
unpack
q
)
...
@@ -134,7 +135,47 @@ selectContactViaDoc cId aId q = proc () -> do
...
@@ -134,7 +135,47 @@ selectContactViaDoc cId aId q = proc () -> do
returnA
-<
FacetPaired
(
contact
^.
node_id
)
returnA
-<
FacetPaired
(
contact
^.
node_id
)
(
contact
^.
node_date
)
(
contact
^.
node_date
)
(
contact
^.
node_hyperdata
)
(
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
queryContactViaDoc
::
O
.
Query
(
NodeSearchRead
,
(
NodeNodeReadNull
,
(
NodeNodeReadNull
...
...
src/Gargantext/Database/Query/Facet.hs
View file @
b3ad95a1
...
@@ -30,6 +30,7 @@ module Gargantext.Database.Query.Facet
...
@@ -30,6 +30,7 @@ module Gargantext.Database.Query.Facet
,
FacetPaired
(
..
)
,
FacetPaired
(
..
)
,
FacetPairedRead
,
FacetPairedRead
,
FacetPairedReadNull
,
FacetPairedReadNull
,
FacetPairedReadNullAgg
,
OrderBy
(
..
)
,
OrderBy
(
..
)
)
)
where
where
...
@@ -121,6 +122,8 @@ data FacetPaired id date hyperdata score =
...
@@ -121,6 +122,8 @@ data FacetPaired id date hyperdata score =
$
(
deriveJSON
(
unPrefix
"_fp_"
)
''
F
acetPaired
)
$
(
deriveJSON
(
unPrefix
"_fp_"
)
''
F
acetPaired
)
$
(
makeAdaptorAndInstance
"pFacetPaired"
''
F
acetPaired
)
$
(
makeAdaptorAndInstance
"pFacetPaired"
''
F
acetPaired
)
instance
(
ToSchema
id
instance
(
ToSchema
id
,
ToSchema
date
,
ToSchema
date
,
ToSchema
hyperdata
,
ToSchema
hyperdata
...
@@ -149,6 +152,21 @@ type FacetPairedReadNull = FacetPaired (Column (Nullable PGInt4) )
...
@@ -149,6 +152,21 @@ type FacetPairedReadNull = FacetPaired (Column (Nullable PGInt4) )
(
Column
(
Nullable
PGJsonb
)
)
(
Column
(
Nullable
PGJsonb
)
)
(
Column
(
Nullable
PGInt4
)
)
(
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
-- | JSON instance
...
...
src/Gargantext/Database/Query/Table/NodeNode.hs
View file @
b3ad95a1
...
@@ -97,7 +97,7 @@ getNodeNodeWith pId _ maybeNodeType = runOpaQuery query
...
@@ -97,7 +97,7 @@ getNodeNodeWith pId _ maybeNodeType = runOpaQuery query
------------------------------------------------------------------------
------------------------------------------------------------------------
insertNodeNode
::
[
NodeNode
]
->
Cmd
err
Int
insertNodeNode
::
[
NodeNode
]
->
Cmd
err
Int
insertNodeNode
ns
=
mkCmd
$
\
conn
->
fromIntegral
<$>
(
runInsert_
conn
insertNodeNode
ns
=
mkCmd
$
\
conn
->
fromIntegral
<$>
(
runInsert_
conn
$
Insert
nodeNodeTable
ns'
rCount
Nothing
)
$
Insert
nodeNodeTable
ns'
rCount
(
Just
DoNothing
)
)
where
where
ns'
::
[
NodeNodeWrite
]
ns'
::
[
NodeNodeWrite
]
ns'
=
map
(
\
(
NodeNode
n1
n2
x
y
)
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