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
148
Issues
148
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
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
cf6e168e
Commit
cf6e168e
authored
Oct 18, 2022
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
[MERGE]
parents
ebe7f7ef
e307e00a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
21 deletions
+35
-21
Export.hs
src/Gargantext/API/Node/Document/Export.hs
+1
-1
Table.hs
src/Gargantext/API/Table.hs
+15
-10
Learn.hs
src/Gargantext/Database/Action/Learn.hs
+3
-3
Facet.hs
src/Gargantext/Database/Query/Facet.hs
+16
-7
No files found.
src/Gargantext/API/Node/Document/Export.hs
View file @
cf6e168e
...
...
@@ -40,7 +40,7 @@ getDocumentsJSON :: UserId
getDocumentsJSON
uId
pId
=
do
mcId
<-
getClosestParentIdByType
pId
NodeCorpus
let
cId
=
maybe
(
panic
"[G.A.N.D.Export] Node has no parent"
)
identity
mcId
docs
<-
runViewDocuments
cId
False
Nothing
Nothing
Nothing
Nothing
docs
<-
runViewDocuments
cId
False
Nothing
Nothing
Nothing
Nothing
Nothing
pure
$
DocumentExport
{
_de_documents
=
mapFacetDoc
<$>
docs
,
_de_garg_version
=
T
.
pack
$
showVersion
PG
.
version
}
where
...
...
src/Gargantext/API/Table.hs
View file @
cf6e168e
...
...
@@ -61,6 +61,7 @@ type TableApi = Summary "Table API"
:>
QueryParam
"offset"
Int
:>
QueryParam
"orderBy"
OrderBy
:>
QueryParam
"query"
Text
:>
QueryParam
"year"
Text
:>
Get
'[
J
SON
]
(
HashedResponse
FacetTableResult
)
:<|>
Summary
"Table API (POST)"
:>
ReqBody
'[
J
SON
]
TableQuery
...
...
@@ -106,14 +107,16 @@ getTableApi :: NodeId
->
Maybe
Int
->
Maybe
OrderBy
->
Maybe
Text
->
Maybe
Text
->
Cmd
err
(
HashedResponse
FacetTableResult
)
getTableApi
cId
tabType
_mListId
mLimit
mOffset
mOrderBy
mQuery
=
do
getTableApi
cId
tabType
_mListId
mLimit
mOffset
mOrderBy
mQuery
mYear
=
do
printDebug
"[getTableApi] mQuery"
mQuery
t
<-
getTable
cId
tabType
mOffset
mLimit
mOrderBy
mQuery
printDebug
"[getTableApi] mYear"
mYear
t
<-
getTable
cId
tabType
mOffset
mLimit
mOrderBy
mQuery
mYear
pure
$
constructHashedResponse
t
postTableApi
::
NodeId
->
TableQuery
->
Cmd
err
FacetTableResult
postTableApi
cId
(
TableQuery
o
l
order
ft
""
)
=
getTable
cId
(
Just
ft
)
(
Just
o
)
(
Just
l
)
(
Just
order
)
Nothing
postTableApi
cId
(
TableQuery
o
l
order
ft
""
)
=
getTable
cId
(
Just
ft
)
(
Just
o
)
(
Just
l
)
(
Just
order
)
Nothing
Nothing
postTableApi
cId
(
TableQuery
o
l
order
ft
q
)
=
case
ft
of
Docs
->
searchInCorpus'
cId
False
[
q
]
(
Just
o
)
(
Just
l
)
(
Just
order
)
Trash
->
searchInCorpus'
cId
True
[
q
]
(
Just
o
)
(
Just
l
)
(
Just
order
)
...
...
@@ -121,7 +124,7 @@ postTableApi cId (TableQuery o l order ft q) = case ft of
getTableHashApi
::
NodeId
->
Maybe
TabType
->
Cmd
err
Text
getTableHashApi
cId
tabType
=
do
HashedResponse
{
hash
=
h
}
<-
getTableApi
cId
tabType
Nothing
Nothing
Nothing
Nothing
Nothing
HashedResponse
{
hash
=
h
}
<-
getTableApi
cId
tabType
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
pure
h
searchInCorpus'
::
CorpusId
...
...
@@ -143,10 +146,11 @@ getTable :: NodeId
->
Maybe
Limit
->
Maybe
OrderBy
->
Maybe
Text
->
Maybe
Text
->
Cmd
err
FacetTableResult
getTable
cId
ft
o
l
order
query
=
do
docs
<-
getTable'
cId
ft
o
l
order
query
docsCount
<-
runCountDocuments
cId
(
ft
==
Just
Trash
)
query
getTable
cId
ft
o
l
order
query
year
=
do
docs
<-
getTable'
cId
ft
o
l
order
query
year
docsCount
<-
runCountDocuments
cId
(
ft
==
Just
Trash
)
query
year
pure
$
TableResult
{
tr_docs
=
docs
,
tr_count
=
docsCount
}
getTable'
::
NodeId
...
...
@@ -155,11 +159,12 @@ getTable' :: NodeId
->
Maybe
Limit
->
Maybe
OrderBy
->
Maybe
Text
->
Maybe
Text
->
Cmd
err
[
FacetDoc
]
getTable'
cId
ft
o
l
order
query
=
getTable'
cId
ft
o
l
order
query
year
=
case
ft
of
(
Just
Docs
)
->
runViewDocuments
cId
False
o
l
order
query
(
Just
Trash
)
->
runViewDocuments
cId
True
o
l
order
query
(
Just
Docs
)
->
runViewDocuments
cId
False
o
l
order
query
year
(
Just
Trash
)
->
runViewDocuments
cId
True
o
l
order
query
year
(
Just
MoreFav
)
->
moreLike
cId
o
l
order
IsFav
(
Just
MoreTrash
)
->
moreLike
cId
o
l
order
IsTrash
x
->
panic
$
"not implemented in getTable: "
<>
(
cs
$
show
x
)
...
...
src/Gargantext/Database/Action/Learn.hs
View file @
cf6e168e
...
...
@@ -44,10 +44,10 @@ getPriors :: HasDBid NodeType => FavOrTrash -> CorpusId -> Cmd err (Events Bool)
getPriors
ft
cId
=
do
docs_fav
<-
filter
(
\
(
FacetDoc
_
_
_
_
f
_
_
)
->
f
==
Just
2
)
<$>
runViewDocuments
cId
False
Nothing
Nothing
Nothing
Nothing
<$>
runViewDocuments
cId
False
Nothing
Nothing
Nothing
Nothing
Nothing
docs_trash
<-
List
.
take
(
List
.
length
docs_fav
)
<$>
runViewDocuments
cId
True
Nothing
Nothing
Nothing
Nothing
<$>
runViewDocuments
cId
True
Nothing
Nothing
Nothing
Nothing
Nothing
let
priors
=
priorEventsWith
text
(
fav2bool
ft
)
(
List
.
zip
(
repeat
False
)
docs_fav
...
...
@@ -62,7 +62,7 @@ moreLikeWith :: HasDBid NodeType
moreLikeWith
cId
o
l
order
ft
priors
=
do
docs_test
<-
filter
(
\
(
FacetDoc
_
_
_
_
f
_
_
)
->
f
==
Just
1
)
<$>
runViewDocuments
cId
False
o
Nothing
order
Nothing
<$>
runViewDocuments
cId
False
o
Nothing
order
Nothing
Nothing
let
results
=
map
fst
$
filter
((
==
)
(
Just
$
not
$
fav2bool
ft
)
.
snd
)
...
...
src/Gargantext/Database/Query/Facet.hs
View file @
cf6e168e
...
...
@@ -301,26 +301,28 @@ runViewDocuments :: HasDBid NodeType
->
Maybe
Limit
->
Maybe
OrderBy
->
Maybe
Text
->
Maybe
Text
->
Cmd
err
[
FacetDoc
]
runViewDocuments
cId
t
o
l
order
query
=
do
runViewDocuments
cId
t
o
l
order
query
year
=
do
printDebug
"[runViewDocuments] sqlQuery"
$
showSql
sqlQuery
runOpaQuery
$
filterWith
o
l
order
sqlQuery
where
sqlQuery
=
viewDocuments
cId
t
(
toDBid
NodeDocument
)
query
sqlQuery
=
viewDocuments
cId
t
(
toDBid
NodeDocument
)
query
year
runCountDocuments
::
HasDBid
NodeType
=>
CorpusId
->
IsTrash
->
Maybe
Text
->
Cmd
err
Int
runCountDocuments
cId
t
mQuery
=
do
runCountDocuments
::
HasDBid
NodeType
=>
CorpusId
->
IsTrash
->
Maybe
Text
->
Maybe
Text
->
Cmd
err
Int
runCountDocuments
cId
t
mQuery
mYear
=
do
runCountOpaQuery
sqlQuery
where
sqlQuery
=
viewDocuments
cId
t
(
toDBid
NodeDocument
)
mQuery
sqlQuery
=
viewDocuments
cId
t
(
toDBid
NodeDocument
)
mQuery
mYear
viewDocuments
::
CorpusId
->
IsTrash
->
NodeTypeId
->
Maybe
Text
->
Maybe
Text
->
Select
FacetDocRead
viewDocuments
cId
t
ntId
mQuery
=
viewDocumentsQuery
cId
t
ntId
mQuery
>>>
proc
(
c
,
nc
)
->
do
viewDocuments
cId
t
ntId
mQuery
mYear
=
viewDocumentsQuery
cId
t
ntId
mQuery
mYear
>>>
proc
(
c
,
nc
)
->
do
returnA
-<
FacetDoc
{
facetDoc_id
=
_cs_id
c
,
facetDoc_created
=
_cs_date
c
,
facetDoc_title
=
_cs_name
c
...
...
@@ -334,8 +336,9 @@ viewDocumentsQuery :: CorpusId
->
IsTrash
->
NodeTypeId
->
Maybe
Text
->
Maybe
Text
->
Select
(
ContextSearchRead
,
NodeContextRead
)
viewDocumentsQuery
cId
t
ntId
mQuery
=
proc
()
->
do
viewDocumentsQuery
cId
t
ntId
mQuery
mYear
=
proc
()
->
do
c
<-
queryContextSearchTable
-<
()
nc
<-
queryNodeContextTable
-<
()
restrict
-<
c
^.
cs_id
.==
nc
^.
nc_context_id
...
...
@@ -346,14 +349,20 @@ viewDocumentsQuery cId t ntId mQuery = proc () -> do
let
query
=
(
fromMaybe
""
mQuery
)
year
=
(
fromMaybe
""
mYear
)
iLikeQuery
=
T
.
intercalate
""
[
"%"
,
query
,
"%"
]
abstractLHS
h
=
fromNullable
(
sqlStrictText
""
)
$
toNullable
h
.->>
(
sqlStrictText
"abstract"
)
yearLHS
h
=
fromNullable
(
sqlStrictText
""
)
$
toNullable
h
.->>
(
sqlStrictText
"publication_year"
)
restrict
-<
if
query
==
""
then
sqlBool
True
else
((
c
^.
cs_name
)
`
ilike
`
(
sqlStrictText
iLikeQuery
))
.||
((
abstractLHS
(
c
^.
cs_hyperdata
))
`
ilike
`
(
sqlStrictText
iLikeQuery
))
restrict
-<
if
year
==
""
then
sqlBool
True
else
(
yearLHS
(
c
^.
cs_hyperdata
))
.==
(
sqlStrictText
year
)
returnA
-<
(
c
,
nc
)
...
...
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