Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
istex
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
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
istex
Commits
a242ae85
Verified
Commit
a242ae85
authored
Mar 19, 2025
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[aeson] fix incomplete pattern matches in ISTEX.Client parsing
parent
5f1f42e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
14 deletions
+16
-14
crawlerISTEX.cabal
crawlerISTEX.cabal
+1
-1
Client.hs
src/ISTEX/Client.hs
+15
-13
No files found.
crawlerISTEX.cabal
View file @
a242ae85
...
...
@@ -44,7 +44,7 @@ common defaults
, servant >= 0.20 && < 0.21
, servant-client >= 0.20 && < 0.21
, text >= 2.0.2 && < 2.2
ghc-options: -Wall -W
unused-imports -Wunused-binds -Wmissing-signature
s -Werror
ghc-options: -Wall -W
incomplete-uni-patterns -Wmissing-signatures -Wunused-imports -Wunused-bind
s -Werror
library
import:
...
...
src/ISTEX/Client.hs
View file @
a242ae85
...
...
@@ -3,16 +3,14 @@
module
ISTEX.Client
where
import
Control.Applicative
((
<|>
))
import
Control.Lens
qualified
as
L
import
Data.Aeson
import
Data.Proxy
(
Proxy
(
..
))
import
Data.Text
qualified
as
T
import
GHC.Generics
import
Text.Read
(
readEither
)
import
Servant.API
import
Servant.Client
import
Data.Proxy
(
Proxy
(
..
))
import
qualified
Data.Text
as
T
import
qualified
Control.Lens
as
L
import
Text.Read
(
readEither
)
data
Author
=
Author
{
_author_name
::
T
.
Text
...
...
@@ -21,8 +19,10 @@ data Author = Author
L
.
makeLenses
''
A
uthor
instance
FromJSON
Author
where
parseJSON
(
Object
o
)
=
Author
<$>
(
o
.:
"name"
)
<*>
(
o
.:
"affiliations"
<|>
pure
[]
)
parseJSON
=
withObject
"Author"
$
\
o
->
do
_author_name
<-
o
.:
"name"
_author_affiliations
<-
o
.:
"affiliations"
<|>
pure
[]
pure
$
Author
{
..
}
data
Source
=
Source
{
_source_title
::
Maybe
T
.
Text
...
...
@@ -41,7 +41,7 @@ parsePubDate (Just pubDate) =
ePubDate
=
readEither
(
T
.
unpack
pubDate
)
::
Either
String
Int
instance
FromJSON
Source
where
parseJSON
(
Object
o
)
=
do
parseJSON
=
withObject
"Source"
$
\
o
->
do
_source_title
<-
o
.:?
"title"
-- _source_authors <- o .:? "author"
mPubDate
<-
o
.:?
"publicationDate"
...
...
@@ -60,7 +60,7 @@ data Document = Document
L
.
makeLenses
''
D
ocument
instance
FromJSON
Document
where
parseJSON
(
Object
o
)
=
do
parseJSON
=
withObject
"Document"
$
\
o
->
do
_document_id
<-
o
.:
"id"
<|>
o
.:
"_id"
_document_title
<-
o
.:?
"title"
_document_authors
<-
o
.:
"author"
<|>
pure
[]
...
...
@@ -76,8 +76,10 @@ data Documents = Documents
}
deriving
(
Show
,
Generic
)
L
.
makeLenses
''
D
ocuments
instance
FromJSON
Documents
where
parseJSON
(
Object
o
)
=
Documents
<$>
(
o
.:
"total"
)
<*>
(
o
.:
"hits"
)
parseJSON
=
withObject
"Documents"
$
\
o
->
do
_documents_total
<-
o
.:
"total"
_documents_hits
<-
o
.:
"hits"
pure
$
Documents
{
..
}
instance
Semigroup
Documents
where
(
<>
)
(
Documents
{
_documents_total
,
_documents_hits
=
d1
})
...
...
@@ -96,7 +98,7 @@ data ScrollResponse = ScrollResponse
L
.
makeLenses
''
S
crollResponse
instance
FromJSON
ScrollResponse
where
parseJSON
(
Object
o
)
=
do
parseJSON
=
withObject
"ScrollResponse"
$
\
o
->
do
_documents_total
<-
o
.:
"total"
_documents_hits
<-
o
.:
"hits"
_scroll_noMoreScrollResults
<-
o
.:?
"noMoreScrollResults"
...
...
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