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
144
Issues
144
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
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
56d97d26
Commit
56d97d26
authored
Nov 26, 2024
by
Yoelis Acourt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add backend filters handlers
parent
4327e2a6
Pipeline
#7043
failed with stages
in 22 minutes and 15 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
11 deletions
+24
-11
New.hs
src/Gargantext/API/Node/Corpus/New.hs
+2
-1
Types.hs
src/Gargantext/API/Node/Types.hs
+1
-0
API.hs
src/Gargantext/Core/Text/Corpus/API.hs
+6
-2
OpenAlex.hs
src/Gargantext/Core/Text/Corpus/API/OpenAlex.hs
+10
-4
Flow.hs
src/Gargantext/Database/Action/Flow.hs
+5
-4
No files found.
src/Gargantext/API/Node/Corpus/New.hs
View file @
56d97d26
...
...
@@ -158,6 +158,7 @@ addToCorpusWithQuery user cid (WithQuery { _wq_query = q
,
_wq_databases
=
dbs
,
_wq_datafield
=
datafield
,
_wq_lang
=
l
,
_wq_filters
=
filters
,
_wq_flowListWith
=
flw
,
_wq_pubmedAPIKey
=
mPubmedAPIKey
,
..
})
maybeLimit
jobHandle
=
do
...
...
@@ -192,7 +193,7 @@ addToCorpusWithQuery user cid (WithQuery { _wq_query = q
let
db
=
database2origin
dbs
-- mPubmedAPIKey <- getUserPubmedAPIKey user
-- printDebug "[addToCorpusWithQuery] mPubmedAPIKey" mPubmedAPIKey
eTxt
<-
getDataText
db
(
Multi
l
)
q
mPubmedAPIKey
mEPOAuthKey
maybeLimit
eTxt
<-
getDataText
db
(
Multi
l
)
q
filters
mPubmedAPIKey
mEPOAuthKey
maybeLimit
-- printDebug "[G.A.N.C.New] lTxts" lTxts
case
eTxt
of
...
...
src/Gargantext/API/Node/Types.hs
View file @
56d97d26
...
...
@@ -87,6 +87,7 @@ data WithQuery = WithQuery
,
_wq_databases
::
!
Database
,
_wq_datafield
::
!
(
Maybe
Datafield
)
,
_wq_lang
::
!
Lang
,
_wq_filters
::
!
(
Maybe
Text
)
,
_wq_node_id
::
!
Int
,
_wq_flowListWith
::
!
FlowSocialListWith
,
_wq_pubmedAPIKey
::
!
(
Maybe
Text
)
...
...
src/Gargantext/Core/Text/Corpus/API.hs
View file @
56d97d26
...
...
@@ -38,6 +38,7 @@ import Gargantext.Prelude hiding (get)
import
Gargantext.Utils.Jobs.Error
import
PUBMED.Types
qualified
as
PUBMED
import
Servant.Client
(
ClientError
)
import
Debug.Pretty.Simple
data
GetCorpusError
=
-- | We couldn't parse the user input query into something meaningful.
...
...
@@ -53,12 +54,15 @@ instance ToHumanFriendlyError GetCorpusError where
ExternalAPIError
api
_
->
"There was a network problem while contacting the "
<>
T
.
pack
(
show
api
)
<>
" API provider. Please try again later or contact your network administrator."
-- | Get External API metadata main function
get
::
ExternalAPIs
->
Lang
-- ^ A user-selected language in which documents needs to be retrieved.
-- If the provider doesn't support the search filtered by language, or if the language
-- is not important, the frontend will simply send 'EN' to the backend.
->
Maybe
Text
->
Corpus
.
RawQuery
->
Maybe
PUBMED
.
APIKey
->
Maybe
EPO
.
AuthKey
...
...
@@ -66,14 +70,14 @@ get :: ExternalAPIs
->
Maybe
Corpus
.
Limit
-- -> IO [HyperdataDocument]
->
IO
(
Either
GetCorpusError
(
Maybe
Integer
,
ConduitT
()
HyperdataDocument
IO
()
))
get
externalAPI
lang
q
mPubmedAPIKey
epoAuthKey
epoAPIUrl
limit
=
do
get
externalAPI
lang
maybeFilters
q
mPubmedAPIKey
epoAuthKey
epoAPIUrl
limit
=
do
-- For PUBMED, HAL, IsTex, Isidore and OpenAlex, we want to send the query as-it.
-- For Arxiv we parse the query into a structured boolean query we submit over.
case
externalAPI
of
PubMed
->
first
(
ExternalAPIError
externalAPI
)
<$>
PUBMED
.
get
(
fromMaybe
""
mPubmedAPIKey
)
q
limit
OpenAlex
->
first
(
ExternalAPIError
externalAPI
)
<$>
OpenAlex
.
get
(
fromMaybe
""
Nothing
{- email -}
)
q
(
Just
$
toISO639
lang
)
limit
first
(
ExternalAPIError
externalAPI
)
<$>
OpenAlex
.
get
(
fromMaybe
""
Nothing
{- email -}
)
q
maybeFilters
limit
Arxiv
->
runExceptT
$
do
corpusQuery
<-
ExceptT
(
pure
parse_query
)
ExceptT
$
fmap
Right
(
Arxiv
.
get
lang
corpusQuery
limit
)
...
...
src/Gargantext/Core/Text/Corpus/API/OpenAlex.hs
View file @
56d97d26
...
...
@@ -23,13 +23,19 @@ import Servant.Client (ClientError)
get
::
Text
->
Corpus
.
RawQuery
->
Maybe
ISO639
.
ISO639_1
->
Maybe
Text
->
Maybe
Limit
->
IO
(
Either
ClientError
(
Maybe
Integer
,
ConduitT
()
HyperdataDocument
IO
()
))
get
_email
q
lang
mLimit
=
do
get
_email
q
maybeFilters
mLimit
=
do
let
limit
=
getLimit
$
fromMaybe
1000
mLimit
let
mFilter
=
(
\
l
->
"language:"
<>
iso639ToText
l
)
<$>
lang
eRes
<-
OA
.
fetchWorksC
Nothing
mFilter
$
Just
$
Corpus
.
getRawQuery
q
let
maybeJoinedFilters
=
[
maybeFilters
]
&
catMaybes
&
intersperse
","
&
mconcat
&
Just
_
<-
trace
(
"JOINED"
<>
(
show
maybeJoinedFilters
::
Text
))
$
return
()
eRes
<-
OA
.
fetchWorksC
Nothing
maybeJoinedFilters
$
Just
$
Corpus
.
getRawQuery
q
pure
$
(
\
(
len
,
docsC
)
->
(
len
,
docsC
.|
takeC
limit
.|
mapC
toDoc
))
<$>
eRes
toDoc
::
OA
.
Work
->
HyperdataDocument
...
...
src/Gargantext/Database/Action/Flow.hs
View file @
56d97d26
...
...
@@ -132,15 +132,16 @@ getDataText :: (HasNodeError err)
=>
DataOrigin
->
TermType
Lang
->
API
.
RawQuery
->
Maybe
Text
->
Maybe
PUBMED
.
APIKey
->
Maybe
EPO
.
AuthKey
->
Maybe
API
.
Limit
->
DBCmd'
env
err
(
Either
API
.
GetCorpusError
DataText
)
getDataText
(
ExternalOrigin
api
)
la
q
mPubmedAPIKey
mAuthKey
li
=
do
getDataText
(
ExternalOrigin
api
)
la
q
filters
mPubmedAPIKey
mAuthKey
li
=
do
cfg
<-
view
hasConfig
eRes
<-
liftBase
$
API
.
get
api
(
_tt_lang
la
)
q
mPubmedAPIKey
mAuthKey
(
_ac_epo_api_url
$
_gc_apis
cfg
)
li
eRes
<-
liftBase
$
API
.
get
api
(
_tt_lang
la
)
filters
q
mPubmedAPIKey
mAuthKey
(
_ac_epo_api_url
$
_gc_apis
cfg
)
li
pure
$
DataNew
<$>
eRes
getDataText
(
InternalOrigin
_
)
la
q
_
_
_li
=
do
getDataText
(
InternalOrigin
_
)
la
q
_
_
_
_
li
=
do
(
_masterUserId
,
_masterRootId
,
cId
)
<-
getOrMkRootWithCorpus
MkCorpusUserMaster
(
Nothing
::
Maybe
HyperdataCorpus
)
ids
<-
map
fst
<$>
searchDocInDatabase
cId
(
stem
(
_tt_lang
la
)
GargPorterAlgorithm
$
API
.
getRawQuery
q
)
pure
$
Right
$
DataOld
ids
...
...
@@ -152,7 +153,7 @@ getDataText_Debug :: (HasNodeError err)
->
Maybe
API
.
Limit
->
DBCmd'
env
err
()
getDataText_Debug
a
l
q
li
=
do
result
<-
getDataText
a
l
q
Nothing
Nothing
li
result
<-
getDataText
a
l
q
Nothing
Nothing
Nothing
li
case
result
of
Left
err
->
liftBase
$
putText
$
show
err
Right
res
->
liftBase
$
printDataText
res
...
...
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