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
160
Issues
160
List
Board
Labels
Milestones
Merge Requests
14
Merge Requests
14
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
7a46e772
Commit
7a46e772
authored
Jul 04, 2024
by
Karen Konou
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Graph/Phylo] Doclist filtering
parent
e73b0fb3
Pipeline
#6323
passed with stages
in 34 minutes and 24 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
14 deletions
+33
-14
Context.hs
src/Gargantext/API/GraphQL/Context.hs
+5
-4
NodeContext.hs
src/Gargantext/Database/Query/Table/NodeContext.hs
+28
-10
No files found.
src/Gargantext/API/GraphQL/Context.hs
View file @
7a46e772
...
...
@@ -22,7 +22,8 @@ import Data.Morpheus.Types
,
ResolverM
,
QUERY
)
import
Data.Text
(
pack
)
import
Data.Text
(
pack
,
unpack
)
import
qualified
Data.Text
as
Text
import
Data.Time.Format.ISO8601
(
iso8601Show
)
import
Gargantext.API.Admin.Types
(
HasSettings
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
...
...
@@ -94,7 +95,7 @@ data ContextsForNgramsArgs
=
ContextsForNgramsArgs
{
corpus_id
::
Int
,
ngrams_terms
::
[
Text
]
,
and_logic
::
Bool
,
and_logic
::
Text
}
deriving
(
Generic
,
GQLType
)
data
NodeContextCategoryMArgs
=
NodeContextCategoryMArgs
...
...
@@ -150,9 +151,9 @@ dbNodeContext context_id node_id = do
-- | Returns list of `ContextGQL` for given ngrams in given corpus id.
dbContextForNgrams
::
(
CmdCommon
env
)
=>
Int
->
[
Text
]
->
Bool
->
GqlM
e
env
[
ContextGQL
]
=>
Int
->
[
Text
]
->
Text
->
GqlM
e
env
[
ContextGQL
]
dbContextForNgrams
node_id
ngrams_terms
and_logic
=
do
contextsForNgramsTerms
<-
lift
$
getContextsForNgramsTerms
(
UnsafeMkNodeId
node_id
)
ngrams_terms
and_logic
contextsForNgramsTerms
<-
lift
$
getContextsForNgramsTerms
(
UnsafeMkNodeId
node_id
)
ngrams_terms
(
readMaybe
$
unpack
$
Text
.
toTitle
and_logic
)
--lift $ printDebug "[dbContextForNgrams] contextsForNgramsTerms" contextsForNgramsTerms
pure
$
toContextGQL
<$>
contextsForNgramsTerms
...
...
src/Gargantext/Database/Query/Table/NodeContext.hs
View file @
7a46e772
...
...
@@ -152,11 +152,11 @@ data ContextForNgramsTerms =
getContextsForNgramsTerms
::
HasNodeError
err
=>
NodeId
->
[
Text
]
->
Bool
->
Maybe
Bool
->
DBCmd
err
[
ContextForNgramsTerms
]
getContextsForNgramsTerms
cId
ngramsTerms
and_logic
=
do
getContextsForNgramsTerms
cId
ngramsTerms
(
Just
True
)
=
do
let
terms_length
=
length
ngramsTerms
res
<-
runPGSQuery
(
query
and_logic
)
(
cId
,
PGS
.
In
ngramsTerms
,
terms_length
)
res
<-
runPGSQuery
query
(
cId
,
PGS
.
In
ngramsTerms
,
terms_length
)
pure
$
(
\
(
_cfnt_nodeId
,
_cfnt_hash
,
_cfnt_nodeTypeId
...
...
@@ -168,8 +168,8 @@ getContextsForNgramsTerms cId ngramsTerms and_logic = do
,
_cfnt_score
,
_cfnt_category
)
->
ContextForNgramsTerms
{
..
})
<$>
res
where
query
::
Bool
->
PGS
.
Query
query
False
=
[
sql
|
SELECT t.id, t.hash_id, t.typename, t.user_id, t.parent_id, t.name, t.date, t.hyperdata, t.score, t.category
query
::
PGS
.
Query
query
=
[
sql
|
SELECT t.id, t.hash_id, t.typename, t.user_id, t.parent_id, t.name, t.date, t.hyperdata, t.score, t.category
FROM (
SELECT DISTINCT ON (contexts.id)
contexts.id AS id,
...
...
@@ -188,11 +188,31 @@ getContextsForNgramsTerms cId ngramsTerms and_logic = do
JOIN nodes_contexts ON contexts.id = nodes_contexts.context_id
JOIN ngrams ON context_node_ngrams.ngrams_id = ngrams.id
WHERE nodes_contexts.node_id = ?
AND ngrams.terms IN ?) t
AND ngrams.terms IN ?
GROUP BY
contexts.id,
nodes_contexts.score,
nodes_contexts.category
HAVING COUNT(DISTINCT ngrams.terms) = ?) t
-- ORDER BY t.doc_count DESC
ORDER BY t.score DESC
|]
query
True
=
[
sql
|
SELECT t.id, t.hash_id, t.typename, t.user_id, t.parent_id, t.name, t.date, t.hyperdata, t.score, t.category
getContextsForNgramsTerms
cId
ngramsTerms
_
=
do
res
<-
runPGSQuery
query
(
cId
,
PGS
.
In
ngramsTerms
)
pure
$
(
\
(
_cfnt_nodeId
,
_cfnt_hash
,
_cfnt_nodeTypeId
,
_cfnt_userId
,
_cfnt_parentId
,
_cfnt_c_title
,
_cfnt_date
,
_cfnt_hyperdata
,
_cfnt_score
,
_cfnt_category
)
->
ContextForNgramsTerms
{
..
})
<$>
res
where
query
::
PGS
.
Query
query
=
[
sql
|
SELECT t.id, t.hash_id, t.typename, t.user_id, t.parent_id, t.name, t.date, t.hyperdata, t.score, t.category
FROM (
SELECT DISTINCT ON (contexts.id)
contexts.id AS id,
...
...
@@ -211,9 +231,7 @@ getContextsForNgramsTerms cId ngramsTerms and_logic = do
JOIN nodes_contexts ON contexts.id = nodes_contexts.context_id
JOIN ngrams ON context_node_ngrams.ngrams_id = ngrams.id
WHERE nodes_contexts.node_id = ?
AND ngrams.terms IN ?
GROUP BY contexts.id
HAVING COUNT(DISTINCT ngrams.terms) = ?) t
AND ngrams.terms IN ?) t
-- ORDER BY t.doc_count DESC
ORDER BY t.score DESC
|]
...
...
Przemyslaw Kaminski
@cgenie
mentioned in commit
5660aec0
·
Oct 08, 2024
mentioned in commit
5660aec0
mentioned in commit 5660aec07ec5a0a0a5468f440092c1a8f57a864e
Toggle commit list
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