Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pubmed
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
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
pubmed
Commits
63eb8187
Commit
63eb8187
authored
Nov 24, 2022
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some main.hs work for better tests
This doesn't compile yet.
parent
b78bdc85
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
3 deletions
+78
-3
Main.hs
app/Main.hs
+70
-3
crawlerPubMed.cabal
crawlerPubMed.cabal
+6
-0
package.yaml
package.yaml
+2
-0
No files found.
app/Main.hs
View file @
63eb8187
module
Main
where
import
PUBMED
(
getMetadataWith
)
import
Data.Semigroup
((
<>
))
import
qualified
Data.Text
as
Text
import
Options.Applicative
import
System.Environment
(
getArgs
)
import
PUBMED
(
getMetadataWith
,
getMetadataWithC
)
import
PUBMED.Types
data
MetaParams
=
MetaParams
{
mp_mAPIKey
::
Maybe
String
,
mp_term
::
String
}
data
FetchParams
=
FetchParams
{
fp_mAPIKey
::
Maybe
String
,
fp_limit
::
Int
,
fp_term
::
String
}
data
Command
=
Meta
MetaParams
|
Fetch
FetchParams
metaParams
::
Parser
Command
metaParams
=
do
api_key
<-
optional
(
strOption
(
long
"api-key"
<>
metavar
"API_KEY"
<>
help
"Pubmed API key"
))
term
<-
strArgument
(
metavar
"term"
)
pure
$
Meta
(
MetaParams
api_key
term
)
fetchParams
::
Parser
Command
fetchParams
=
do
api_key
<-
optional
(
strOption
(
long
"api-key"
<>
metavar
"API_KEY"
<>
help
"Pubmed API key"
))
limit
<-
option
auto
(
long
"limit"
<>
help
"Maximum number of documents"
<>
showDefault
<>
value
100
<>
metavar
"INT"
)
term
<-
strArgument
(
metavar
"term"
)
pure
$
Fetch
(
FetchParams
api_key
limit
term
)
params
::
Parser
Command
params
=
metaParams
<|>
fetchParams
opts
::
ParserInfo
Command
opts
=
info
(
params
<**>
helper
)
(
fullDesc
<>
progDesc
"A program to test PUBMD"
<>
header
"crawlerPubMed-exe"
)
main
::
IO
()
main
=
getMetadataWith
config
"bisphenol"
Nothing
(
Just
100
)
>>=
print
main
=
run
=<<
execParser
opts
where
config
=
Config
{
mAPIKey
=
Nothing
}
run
::
Command
->
IO
()
run
(
Meta
(
MetaParams
{
mp_mAPIKey
,
mp_term
}))
=
do
let
config
=
Config
{
mAPIKey
=
Text
.
pack
<$>
mp_mAPIKey
}
eDocs
<-
getMetadataWithC
config
(
Text
.
pack
mp_term
)
Nothing
case
eDocs
of
Left
err
->
print
err
Right
(
count
,
_docs
)
->
print
$
show
count
run
(
Fetch
(
FetchParams
{
fp_mAPIKey
,
fp_term
,
fp_limit
}))
=
do
let
config
=
Config
{
mAPIKey
=
Text
.
pack
<$>
fp_mAPIKey
}
eDocs
<-
getMetadataWithC
config
(
Text
.
pack
fp_term
)
(
Just
$
fromIntegral
fp_limit
)
case
eDocs
of
Left
err
->
print
err
Right
(
count
,
docs
)
->
print
$
show
count
crawlerPubMed.cabal
View file @
63eb8187
...
...
@@ -36,6 +36,7 @@ library
default-extensions:
DataKinds
MultiParamTypeClasses
NamedFieldPuns
OverloadedStrings
TypeOperators
ghc-options: -Wunused-imports
...
...
@@ -52,6 +53,7 @@ library
, http-client-tls
, http-media
, lens
, optparse-applicative
, protolude
, servant
, servant-client
...
...
@@ -68,6 +70,7 @@ executable crawlerPubMed-exe
default-extensions:
DataKinds
MultiParamTypeClasses
NamedFieldPuns
OverloadedStrings
TypeOperators
ghc-options: -threaded -rtsopts -Wunused-imports -with-rtsopts=-N
...
...
@@ -85,6 +88,7 @@ executable crawlerPubMed-exe
, http-client-tls
, http-media
, lens
, optparse-applicative
, protolude
, servant
, servant-client
...
...
@@ -104,6 +108,7 @@ test-suite crawlerPubMed-test
default-extensions:
DataKinds
MultiParamTypeClasses
NamedFieldPuns
OverloadedStrings
TypeOperators
ghc-options: -threaded -rtsopts -with-rtsopts=-N
...
...
@@ -121,6 +126,7 @@ test-suite crawlerPubMed-test
, http-client-tls
, http-media
, lens
, optparse-applicative
, protolude
, servant
, servant-client
...
...
package.yaml
View file @
63eb8187
...
...
@@ -17,6 +17,7 @@ extra-source-files:
default-extensions
:
-
DataKinds
-
MultiParamTypeClasses
-
NamedFieldPuns
-
OverloadedStrings
-
TypeOperators
...
...
@@ -38,6 +39,7 @@ dependencies:
-
http-client-tls
-
http-media
-
lens
-
optparse-applicative
-
protolude
-
servant
-
servant-client
...
...
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