Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
epo-proxy-api-client
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
crawlers
epo-proxy-api-client
Commits
9225d046
Commit
9225d046
authored
Nov 15, 2023
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into 'main'
conduit fetch added See merge request
!2
parents
66aa35a7
56d05015
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletion
+36
-1
epo-api-client.cabal
epo-api-client.cabal
+1
-0
Implementation.hs
src/EPO/API/Client/Implementation.hs
+35
-1
No files found.
epo-api-client.cabal
View file @
9225d046
...
@@ -69,6 +69,7 @@ library
...
@@ -69,6 +69,7 @@ library
-- Other library packages from which modules are imported.
-- Other library packages from which modules are imported.
build-depends: base ^>=4.14.3.0
build-depends: base ^>=4.14.3.0
, aeson ^>= 1.5.6.0
, aeson ^>= 1.5.6.0
, conduit ^>= 1.3.5
, containers ^>= 0.6.7
, containers ^>= 0.6.7
, http-client >= 0.7.13.1 && < 0.8
, http-client >= 0.7.13.1 && < 0.8
, http-client-tls >= 0.3.6.2 && < 0.4
, http-client-tls >= 0.3.6.2 && < 0.4
...
...
src/EPO/API/Client/Implementation.hs
View file @
9225d046
...
@@ -10,16 +10,24 @@ Portability : POSIX
...
@@ -10,16 +10,24 @@ Portability : POSIX
module
EPO.API.Client.Implementation
module
EPO.API.Client.Implementation
(
searchEPOAPI
(
searchEPOAPI
,
searchEPOAPIC
)
)
where
where
import
Conduit
import
EPO.API.Client
import
EPO.API.Client
import
EPO.API.Client.Types
import
EPO.API.Client.Types
import
Network.URI
qualified
as
URI
import
Network.URI
qualified
as
URI
import
Protolude
import
Protolude
import
Servant.Client
(
runClientM
)
import
Servant.Client
(
ClientError
,
runClientM
)
batchSize
::
Int
batchSize
=
20
-- | This is a basic function for searching, don't use it for full
-- search, it fetches whole page at once.
searchEPOAPI
::
URI
.
URI
searchEPOAPI
::
URI
.
URI
->
AuthKey
->
AuthKey
->
Start
->
Start
...
@@ -32,3 +40,29 @@ searchEPOAPI uri auth start end search' = do
...
@@ -32,3 +40,29 @@ searchEPOAPI uri auth start end search' = do
case
eRes
of
case
eRes
of
Left
err
->
throwIO
err
Left
err
->
throwIO
err
Right
res
->
pure
res
Right
res
->
pure
res
searchEPOAPIC
::
URI
.
URI
->
AuthKey
->
Maybe
Start
->
Maybe
End
->
Search
->
IO
(
Either
ClientError
(
Integer
,
ConduitT
()
HyperdataDocument
IO
()
))
searchEPOAPIC
uri
auth
mStart
mEnd
search'
=
do
let
start
=
fromMaybe
1
mStart
env
<-
defaultClientEnv
uri
eRes1
<-
runClientM
(
search
(
Just
auth
)
(
Just
1
)
(
Just
2
)
(
Just
search'
))
env
case
eRes1
of
Left
err
->
pure
$
Left
err
Right
(
Paginated
{
total
})
->
do
let
end
=
fromMaybe
total
mEnd
let
fetch
s
=
do
let
endS
=
minimum
[
s
+
batchSize
-
1
,
end
]
eRes
<-
runClientM
(
search
(
Just
auth
)
(
Just
s
)
(
Just
endS
)
(
Just
search'
))
env
case
eRes
of
Left
err
->
throwIO
err
Right
(
Paginated
{
items
})
->
pure
items
pure
$
Right
(
fromIntegral
total
,
yieldMany
[
start
,
start
+
batchSize
..
end
]
.|
concatMapMC
fetch
)
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