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
32920384
Verified
Commit
32920384
authored
Nov 15, 2023
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[epo] add proxy api integration
parent
dac56414
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
17 deletions
+23
-17
cabal.project
cabal.project
+7
-8
API.hs
src/Gargantext/Core/Text/Corpus/API.hs
+3
-2
EPO.hs
src/Gargantext/Core/Text/Corpus/API/EPO.hs
+9
-5
Flow.hs
src/Gargantext/Database/Action/Flow.hs
+4
-2
No files found.
cabal.project
View file @
32920384
...
...
@@ -6,7 +6,6 @@ with-compiler: ghc-8.10.7
packages
:
./
../
openalex
source
-
repository
-
package
type
:
git
...
...
@@ -82,6 +81,11 @@ source-repository-package
location
:
https
://
gitlab
.
iscpif
.
fr
/
gargantext
/
crawlers
/
arxiv
-
api
.
git
tag
:
eb130c71fa17adaceed6ff66beefbccb13df51ba
source
-
repository
-
package
type
:
git
location
:
https
://
gitlab
.
iscpif
.
fr
/
gargantext
/
crawlers
/
epo
-
proxy
-
api
.
git
tag
:
9225
d046083853200b9045c8d71161e6a234fc5c
source
-
repository
-
package
type
:
git
location
:
https
://
gitlab
.
iscpif
.
fr
/
gargantext
/
crawlers
/
hal
.
git
...
...
@@ -97,11 +101,6 @@ source-repository-package
location
:
https
://
gitlab
.
iscpif
.
fr
/
gargantext
/
iso639
.
git
tag
:
1
a9e23e210a02da3b846d7cdc666541e2148334d
source
-
repository
-
package
type
:
git
location
:
https
://
gitlab
.
iscpif
.
fr
/
gargantext
/
crawlers
/
epo
-
proxy
-
api
.
git
tag
:
eae89b09f4ce46cd3db836d5c580ac90073de7ba
source
-
repository
-
package
type
:
git
location
:
https
://
gitlab
.
iscpif
.
fr
/
gargantext
/
crawlers
/
istex
.
git
...
...
@@ -110,7 +109,7 @@ source-repository-package
source
-
repository
-
package
type
:
git
location
:
https
://
gitlab
.
iscpif
.
fr
/
gargantext
/
crawlers
/
openalex
.
git
tag
:
1
cf872fb3bd0e3e44af31247833c4b6bb7d0dca5
tag
:
a46abe16700449a1f863deb89380b05d89ad9723
source
-
repository
-
package
type
:
git
...
...
@@ -125,7 +124,7 @@ source-repository-package
source
-
repository
-
package
type
:
git
location
:
https
://
gitlab
.
iscpif
.
fr
/
gargantext
/
haskell
-
gargantext
-
prelude
tag
:
40135
d166830690b1101180b79e9fd3663284b2b
tag
:
9
b33568da92f92bfa89c8bd8f05b07b70fd021f9
source
-
repository
-
package
type
:
git
...
...
src/Gargantext/Core/Text/Corpus/API.hs
View file @
32920384
...
...
@@ -50,10 +50,11 @@ get :: ExternalAPIs
->
Corpus
.
RawQuery
->
Maybe
PUBMED
.
APIKey
->
Maybe
EPO
.
AuthKey
->
Text
->
Maybe
Corpus
.
Limit
-- -> IO [HyperdataDocument]
->
IO
(
Either
GetCorpusError
(
Maybe
Integer
,
ConduitT
()
HyperdataDocument
IO
()
))
get
externalAPI
la
q
mPubmedAPIKey
epoAuthKey
limit
=
do
get
externalAPI
la
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
...
...
@@ -73,6 +74,6 @@ get externalAPI la q mPubmedAPIKey epoAuthKey limit = do
docs
<-
ISIDORE
.
get
la
(
Corpus
.
getLimit
<$>
limit
)
(
Just
$
Corpus
.
getRawQuery
q
)
Nothing
pure
$
Right
(
Just
$
fromIntegral
$
length
docs
,
yieldMany
docs
)
EPO
->
do
first
ExternalAPIError
<$>
EPO
.
get
epoAuthKey
q
(
toISO639EN
la
)
limit
first
ExternalAPIError
<$>
EPO
.
get
epoAuthKey
epoAPIUrl
q
(
toISO639EN
la
)
limit
where
parse_query
=
first
(
InvalidInputQuery
q
.
T
.
pack
)
$
Corpus
.
parseQuery
q
src/Gargantext/Core/Text/Corpus/API/EPO.hs
View file @
32920384
...
...
@@ -24,20 +24,24 @@ import Servant.Client.Core (ClientError(ConnectionError))
get
::
Maybe
EPO
.
AuthKey
->
Text
->
Corpus
.
RawQuery
->
ISO639_1
->
Maybe
Corpus
.
Limit
->
IO
(
Either
ClientError
(
Maybe
Integer
,
ConduitT
()
HyperdataDocument
IO
()
))
get
Nothing
_
_
_
=
do
get
Nothing
_
_
_
_
=
do
-- throwIO $ EPO.OtherError "AuthKey is required"
pure
$
Left
$
ConnectionError
$
toException
$
ErrorCall
"AuthKey is required"
get
(
Just
authKey
)
q
lang
mLimit
=
do
get
(
Just
authKey
)
epoAPIUrl
q
lang
mLimit
=
do
let
_limit
=
Corpus
.
getLimit
$
fromMaybe
10000
mLimit
case
parseURI
"http://localhost:3000"
of
case
parseURI
(
T
.
unpack
epoAPIUrl
)
of
Nothing
->
pure
$
Left
$
ConnectionError
$
toException
$
ErrorCall
"Cannot parse API URL"
Just
apiUrl
->
do
EPO
.
Paginated
{
..
}
<-
EPO
.
searchEPOAPI
apiUrl
authKey
1
20
(
Corpus
.
getRawQuery
q
)
pure
$
Right
(
Just
$
fromIntegral
total
,
yieldMany
items
.|
mapC
(
toDoc
lang
)
)
eRes
<-
EPO
.
searchEPOAPIC
apiUrl
authKey
Nothing
(
Just
30
)
(
Corpus
.
getRawQuery
q
)
pure
$
(
\
(
total
,
itemsC
)
->
(
Just
total
,
itemsC
.|
mapC
(
toDoc
lang
)))
<$>
eRes
-- EPO.Paginated { .. } <- EPO.searchEPOAPI apiUrl authKey 1 20 (Corpus.getRawQuery q)
-- pure $ Right ( Just $ fromIntegral total, yieldMany items .| mapC (toDoc lang) )
toDoc
::
ISO639_1
->
EPO
.
HyperdataDocument
->
HyperdataDocument
toDoc
lang
(
EPO
.
HyperdataDocument
{
..
})
=
...
...
src/Gargantext/Database/Action/Flow.hs
View file @
32920384
...
...
@@ -102,7 +102,7 @@ import Gargantext.Database.Action.Search (searchDocInDatabase)
import
Gargantext.Database.Admin.Config
(
userMaster
,
corpusMasterName
)
import
Gargantext.Database.Admin.Types.Hyperdata
import
Gargantext.Database.Admin.Types.Node
hiding
(
DEBUG
)
-- (HyperdataDocument(..), NodeType(..), NodeId, UserId, ListId, CorpusId, RootId, MasterCorpusId, MasterUserId)
import
Gargantext.Database.Prelude
(
DbCmd
'
,
DBCmd
)
import
Gargantext.Database.Prelude
(
DbCmd
'
,
DBCmd
,
hasConfig
)
import
Gargantext.Database.Query.Table.ContextNodeNgrams2
import
Gargantext.Database.Query.Table.Ngrams
import
Gargantext.Database.Query.Table.Node
...
...
@@ -117,6 +117,7 @@ import Gargantext.Database.Schema.Node (NodePoly(..), node_id)
import
Gargantext.Database.Schema.Node
(
node_hyperdata
)
import
Gargantext.Database.Types
import
Gargantext.Prelude
hiding
(
to
)
import
Gargantext.Prelude.Config
(
GargConfig
(
..
))
import
Gargantext.Prelude.Crypto.Hash
(
Hash
)
import
Gargantext.System.Logging
import
Gargantext.Utils.Jobs
(
JobHandle
,
MonadJobStatus
(
..
))
...
...
@@ -165,7 +166,8 @@ getDataText :: (HasNodeError err)
->
Maybe
API
.
Limit
->
DBCmd
err
(
Either
API
.
GetCorpusError
DataText
)
getDataText
(
ExternalOrigin
api
)
la
q
mPubmedAPIKey
mAuthKey
li
=
do
eRes
<-
liftBase
$
API
.
get
api
(
_tt_lang
la
)
q
mPubmedAPIKey
mAuthKey
li
cfg
<-
view
hasConfig
eRes
<-
liftBase
$
API
.
get
api
(
_tt_lang
la
)
q
mPubmedAPIKey
mAuthKey
(
_gc_epo_api_url
cfg
)
li
pure
$
DataNew
<$>
eRes
getDataText
(
InternalOrigin
_
)
_la
q
_
_
_li
=
do
(
_masterUserId
,
_masterRootId
,
cId
)
<-
getOrMk_RootWithCorpus
...
...
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