Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
hal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
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
hal
Commits
63e6bb6c
Commit
63e6bb6c
authored
Dec 20, 2022
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix parsing of docid
Turns out sometimes docid can be a string.
parent
36424845
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
15 deletions
+25
-15
HAL.hs
src/HAL.hs
+2
-2
Client.hs
src/HAL/Client.hs
+1
-1
Corpus.hs
src/HAL/Doc/Corpus.hs
+22
-12
No files found.
src/HAL.hs
View file @
63e6bb6c
src/HAL/Client.hs
View file @
63e6bb6c
...
...
@@ -27,7 +27,7 @@ type Search doc = "search"
:>
QueryParams
"fq"
Text
-- pretty much clear, (Asc || Desc) + field you want to sort by
:>
QueryParam
"sort"
SortField
-- permit to start a the x result
-- permit to start a
t
the x result
:>
QueryParam
"start"
Int
-- use rows to make the request only return the x number of result
:>
QueryParam
"rows"
Integer
...
...
src/HAL/Doc/Corpus.hs
View file @
63e6bb6c
...
...
@@ -4,11 +4,13 @@ module HAL.Doc.Corpus where
import
GHC.Generics
import
Data.Aeson
import
Data.Default
import
Data.Text
(
pack
,
Text
)
import
Control.Applicative
((
<|>
))
import
qualified
Control.Lens
as
L
import
Data.Aeson
import
Data.Aeson.Types
(
Parser
,
explicitParseField
)
import
Data.Default
import
Data.Text
(
pack
,
unpack
,
Text
)
import
Text.Read
(
readMaybe
)
import
Servant.API
(
ToHttpApiData
(
..
))
...
...
@@ -29,8 +31,9 @@ instance Default Corpus where
def
=
Corpus
def
def
def
def
def
def
def
def
instance
FromJSON
Corpus
where
parseJSON
(
Object
o
)
=
Corpus
<$>
(
o
.:
"docid"
)
parseJSON
(
Object
o
)
=
Corpus
<$>
(
explicitParseField
docidParser
o
"docid"
)
<*>
(
o
.:
"title_s"
<|>
return
[]
)
<*>
(
o
.:
"abstract_s"
<|>
return
[]
)
<*>
(
o
.:?
"submittedDate_s"
)
...
...
@@ -39,5 +42,12 @@ instance FromJSON Corpus where
<*>
(
o
.:
"authOrganism_s"
<|>
return
[]
)
<*>
(
o
.:
"structId_i"
<|>
return
[]
)
docidParser
::
Value
->
Parser
Int
docidParser
n
@
(
Number
_
)
=
parseJSON
n
docidParser
(
String
i
)
=
case
(
readMaybe
$
unpack
i
::
Maybe
Int
)
of
Nothing
->
fail
$
"cannot parse int for docid"
Just
i
->
pure
i
docidParser
v
=
fail
$
"cannot parse docid: "
<>
show
v
instance
ToHttpApiData
Corpus
where
toUrlPiece
_
=
"docid,title_s,abstract_s,submittedDate_s,source_s,authFullName_s,authOrganism_s,structId_i"
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