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
149
Issues
149
List
Board
Labels
Milestones
Merge Requests
8
Merge Requests
8
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
ca645b1c
Commit
ca645b1c
authored
Jan 07, 2022
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] Docs Table scores
parent
d807de52
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
86 deletions
+21
-86
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+4
-4
Node.hs
src/Gargantext/API/Node.hs
+3
-2
Flow.hs
src/Gargantext/Database/Action/Flow.hs
+5
-0
List.hs
src/Gargantext/Database/Action/Flow/List.hs
+1
-0
NodeContext.hs
src/Gargantext/Database/Query/Table/NodeContext.hs
+8
-25
NodeNode.hs
src/Gargantext/Database/Query/Table/NodeNode.hs
+0
-55
No files found.
src/Gargantext/API/Ngrams.hs
View file @
ca645b1c
...
...
@@ -343,10 +343,10 @@ tableNgramsPull listId ngramsType p_version = do
-- Apply the given patch to the DB and returns the patch to be applied on the
-- client.
-- TODO-ACCESS check
tableNgramsPut
::
(
HasNodeStory
env
err
m
,
HasInvalidError
err
,
HasSettings
env
,
HasMail
env
tableNgramsPut
::
(
HasNodeStory
env
err
m
,
HasInvalidError
err
,
HasSettings
env
,
HasMail
env
)
=>
TabType
->
ListId
...
...
src/Gargantext/API/Node.hs
View file @
ca645b1c
...
...
@@ -64,6 +64,7 @@ import Gargantext.Database.Query.Table.Node.Error (HasNodeError(..))
import
Gargantext.Database.Query.Table.Node.Update
(
Update
(
..
),
update
)
import
Gargantext.Database.Query.Table.Node.UpdateOpaleye
(
updateHyperdata
)
import
Gargantext.Database.Query.Table.NodeNode
import
Gargantext.Database.Query.Table.NodeContext
(
nodeContextsCategory
,
nodeContextsScore
)
import
Gargantext.Database.Query.Tree
(
tree
,
TreeMode
(
..
))
import
Gargantext.Prelude
import
Gargantext.Core.Viz.Phylo.Legacy.LegacyAPI
(
PhyloAPI
,
phyloAPI
)
...
...
@@ -271,7 +272,7 @@ catApi :: CorpusId -> GargServer CatApi
catApi
=
putCat
where
putCat
::
CorpusId
->
NodesToCategory
->
Cmd
err
[
Int
]
putCat
cId
cs'
=
node
Node
sCategory
$
map
(
\
n
->
(
cId
,
n
,
ntc_category
cs'
))
(
ntc_nodesId
cs'
)
putCat
cId
cs'
=
node
Context
sCategory
$
map
(
\
n
->
(
cId
,
n
,
ntc_category
cs'
))
(
ntc_nodesId
cs'
)
------------------------------------------------------------------------
type
ScoreApi
=
Summary
" To Score NodeNodes"
...
...
@@ -292,7 +293,7 @@ scoreApi :: CorpusId -> GargServer ScoreApi
scoreApi
=
putScore
where
putScore
::
CorpusId
->
NodesToScore
->
Cmd
err
[
Int
]
putScore
cId
cs'
=
node
Node
sScore
$
map
(
\
n
->
(
cId
,
n
,
nts_score
cs'
))
(
nts_nodesId
cs'
)
putScore
cId
cs'
=
node
Context
sScore
$
map
(
\
n
->
(
cId
,
n
,
nts_score
cs'
))
(
nts_nodesId
cs'
)
------------------------------------------------------------------------
-- TODO adapt FacetDoc -> ListDoc (and add type of document as column)
...
...
src/Gargantext/Database/Action/Flow.hs
View file @
ca645b1c
...
...
@@ -268,6 +268,8 @@ flowCorpusUser l user corpusName ctype ids mfslw = do
let
gp
=
GroupWithPosTag
l
CoreNLP
HashMap
.
empty
ngs
<-
buildNgramsLists
user
userCorpusId
masterCorpusId
mfslw
gp
printDebug
"flowCorpusUser:ngs"
ngs
_userListId
<-
flowList_DbRepo
listId
ngs
_mastListId
<-
getOrMkList
masterCorpusId
masterUserId
-- _ <- insertOccsUpdates userCorpusId mastListId
...
...
@@ -327,6 +329,8 @@ saveDocNgramsWith lId mapNgramsDocs' = do
$
map
(
first
_ngramsTerms
.
second
Map
.
keys
)
$
HashMap
.
toList
mapNgramsDocs
printDebug
"saveDocNgramsWith"
mapCgramsId
-- insertDocNgrams
_return
<-
insertContextNodeNgrams2
$
catMaybes
[
ContextNodeNgrams2
<$>
Just
nId
...
...
@@ -336,6 +340,7 @@ saveDocNgramsWith lId mapNgramsDocs' = do
,
(
ngrams_type
,
mapNodeIdWeight
)
<-
Map
.
toList
mapNgramsTypes
,
(
nId
,
w
)
<-
Map
.
toList
mapNodeIdWeight
]
-- to be removed
_
<-
insertDocNgrams
lId
indexedNgrams
...
...
src/Gargantext/Database/Action/Flow/List.hs
View file @
ca645b1c
...
...
@@ -100,6 +100,7 @@ flowList_DbRepo lId ngs = do
_r
<-
insert_Node_NodeNgrams_NodeNgrams
$
map
(
\
(
a
,
b
)
->
Node_NodeNgrams_NodeNgrams
lId
a
b
Nothing
)
toInsert
printDebug
"flowList_Tficf':ngs"
ngs
listInsert
lId
ngs
--trace (show $ List.filter (\n -> _ne_ngrams n == "versatile") $ List.concat $ Map.elems ngs) $ listInsert lId ngs
...
...
src/Gargantext/Database/Query/Table/NodeContext.hs
View file @
ca645b1c
...
...
@@ -101,40 +101,22 @@ deleteNodeContext n c = mkCmd $ \conn ->
------------------------------------------------------------------------
-- | Favorite management
_nodeContextCategory
::
CorpusId
->
DocId
->
Int
->
Cmd
err
[
Int
]
_nodeContextCategory
cId
dId
c
=
map
(
\
(
PGS
.
Only
a
)
->
a
)
<$>
runPGSQuery
favQuery
(
c
,
cId
,
dId
)
where
favQuery
::
PGS
.
Query
favQuery
=
[
sql
|
UPDATE nodes_contexts SET category = ?
WHERE node_id = ? AND context_id = ?
RETURNING context_id;
|]
nodeContextsCategory
::
[(
CorpusId
,
DocId
,
Int
)]
->
Cmd
err
[
Int
]
nodeContextsCategory
inputData
=
map
(
\
(
PGS
.
Only
a
)
->
a
)
<$>
runPGSQuery
cat
Query
(
PGS
.
Only
$
Values
fields
inputData
)
<$>
runPGSQuery
cat
Select
(
PGS
.
Only
$
Values
fields
inputData
)
where
fields
=
map
(
\
t
->
QualifiedIdentifier
Nothing
t
)
[
"int4"
,
"int4"
,
"int4"
]
cat
Query
::
PGS
.
Query
cat
Query
=
[
sql
|
UPDATE nodes_contexts as nn0
cat
Select
::
PGS
.
Query
cat
Select
=
[
sql
|
UPDATE nodes_contexts as nn0
SET category = nn1.category
FROM (?) as nn1(node_id,context_id,category)
WHERE nn0.node
1_id
= nn1.node_id
AND nn0.
node2
_id = nn1.context_id
RETURNING nn1.
context
_id
WHERE nn0.node
_id
= nn1.node_id
AND nn0.
context
_id = nn1.context_id
RETURNING nn1.
node
_id
|]
------------------------------------------------------------------------
-- | Score management
_nodeContextScore
::
CorpusId
->
DocId
->
Int
->
Cmd
err
[
Int
]
_nodeContextScore
cId
dId
c
=
map
(
\
(
PGS
.
Only
a
)
->
a
)
<$>
runPGSQuery
scoreQuery
(
c
,
cId
,
dId
)
where
scoreQuery
::
PGS
.
Query
scoreQuery
=
[
sql
|
UPDATE nodes_contexts SET score = ?
WHERE node_id = ? AND context_id = ?
RETURNING context_id;
|]
nodeContextsScore
::
[(
CorpusId
,
DocId
,
Int
)]
->
Cmd
err
[
Int
]
nodeContextsScore
inputData
=
map
(
\
(
PGS
.
Only
a
)
->
a
)
<$>
runPGSQuery
catScore
(
PGS
.
Only
$
Values
fields
inputData
)
...
...
@@ -144,11 +126,12 @@ nodeContextsScore inputData = map (\(PGS.Only a) -> a)
catScore
=
[
sql
|
UPDATE nodes_contexts as nn0
SET score = nn1.score
FROM (?) as nn1(node_id, context_id, score)
WHERE nn0.node_id = nn1.node_id
WHERE nn0.node_id
= nn1.node_id
AND nn0.context_id = nn1.context_id
RETURNING nn1.context_id
|]
------------------------------------------------------------------------
selectCountDocs
::
HasDBid
NodeType
=>
CorpusId
->
Cmd
err
Int
selectCountDocs
cId
=
runCountOpaQuery
(
queryCountDocs
cId
)
...
...
src/Gargantext/Database/Query/Table/NodeNode.hs
View file @
ca645b1c
...
...
@@ -24,8 +24,6 @@ module Gargantext.Database.Query.Table.NodeNode
,
selectDocsDates
,
selectDocNodes
,
selectDocs
,
nodeNodesCategory
,
nodeNodesScore
,
getNodeNode
,
insertNodeNode
,
deleteNodeNode
...
...
@@ -38,9 +36,6 @@ import Control.Arrow (returnA)
import
Control.Lens
(
view
,
(
^.
))
import
Data.Maybe
(
catMaybes
)
import
Data.Text
(
Text
,
splitOn
)
import
Database.PostgreSQL.Simple.SqlQQ
(
sql
)
import
Database.PostgreSQL.Simple.Types
(
Values
(
..
),
QualifiedIdentifier
(
..
))
import
qualified
Database.PostgreSQL.Simple
as
PGS
(
Query
,
Only
(
..
))
import
qualified
Opaleye
as
O
import
Opaleye
...
...
@@ -124,56 +119,6 @@ deleteNodeNode n1 n2 = mkCmd $ \conn ->
rCount
)
------------------------------------------------------------------------
-- | Favorite management
_nodeNodeCategory
::
CorpusId
->
DocId
->
Int
->
Cmd
err
[
Int
]
_nodeNodeCategory
cId
dId
c
=
map
(
\
(
PGS
.
Only
a
)
->
a
)
<$>
runPGSQuery
favSelect
(
c
,
cId
,
dId
)
where
favSelect
::
PGS
.
Query
favSelect
=
[
sql
|
UPDATE nodes_nodes SET category = ?
WHERE node1_id = ? AND node2_id = ?
RETURNING node2_id;
|]
nodeNodesCategory
::
[(
CorpusId
,
DocId
,
Int
)]
->
Cmd
err
[
Int
]
nodeNodesCategory
inputData
=
map
(
\
(
PGS
.
Only
a
)
->
a
)
<$>
runPGSQuery
catSelect
(
PGS
.
Only
$
Values
fields
inputData
)
where
fields
=
map
(
\
t
->
QualifiedIdentifier
Nothing
t
)
[
"int4"
,
"int4"
,
"int4"
]
catSelect
::
PGS
.
Query
catSelect
=
[
sql
|
UPDATE nodes_nodes as nn0
SET category = nn1.category
FROM (?) as nn1(node1_id,node2_id,category)
WHERE nn0.node1_id = nn1.node1_id
AND nn0.node2_id = nn1.node2_id
RETURNING nn1.node2_id
|]
------------------------------------------------------------------------
-- | Score management
_nodeNodeScore
::
CorpusId
->
DocId
->
Int
->
Cmd
err
[
Int
]
_nodeNodeScore
cId
dId
c
=
map
(
\
(
PGS
.
Only
a
)
->
a
)
<$>
runPGSQuery
scoreSelect
(
c
,
cId
,
dId
)
where
scoreSelect
::
PGS
.
Query
scoreSelect
=
[
sql
|
UPDATE nodes_nodes SET score = ?
WHERE node1_id = ? AND node2_id = ?
RETURNING node2_id;
|]
nodeNodesScore
::
[(
CorpusId
,
DocId
,
Int
)]
->
Cmd
err
[
Int
]
nodeNodesScore
inputData
=
map
(
\
(
PGS
.
Only
a
)
->
a
)
<$>
runPGSQuery
catScore
(
PGS
.
Only
$
Values
fields
inputData
)
where
fields
=
map
(
\
t
->
QualifiedIdentifier
Nothing
t
)
[
"int4"
,
"int4"
,
"int4"
]
catScore
::
PGS
.
Query
catScore
=
[
sql
|
UPDATE nodes_nodes as nn0
SET score = nn1.score
FROM (?) as nn1(node1_id, node2_id, score)
WHERE nn0.node1_id = nn1.node1_id
AND nn0.node2_id = nn1.node2_id
RETURNING nn1.node2_id
|]
------------------------------------------------------------------------
selectCountDocs
::
HasDBid
NodeType
=>
CorpusId
->
Cmd
err
Int
selectCountDocs
cId
=
runCountOpaQuery
(
queryCountDocs
cId
)
...
...
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