Commit 85560639 authored by Fabien Manière's avatar Fabien Manière

parse host.title as sources

parent 45940961
...@@ -27,7 +27,7 @@ instance FromJSON Author where ...@@ -27,7 +27,7 @@ instance FromJSON Author where
data Source = Source data Source = Source
{ _source_title :: Maybe T.Text { _source_title :: Maybe T.Text
, _source_authors :: [Author] -- , _source_authors :: [Author]
, _source_publicationDate :: Maybe Int , _source_publicationDate :: Maybe Int
} deriving (Show, Generic) } deriving (Show, Generic)
L.makeLenses ''Source L.makeLenses ''Source
...@@ -43,9 +43,9 @@ parsePubDate (Just pubDate) = ...@@ -43,9 +43,9 @@ parsePubDate (Just pubDate) =
instance FromJSON Source where instance FromJSON Source where
parseJSON (Object o) = do parseJSON (Object o) = do
_source_title <- o .:? "title" _source_title <- o .:? "title"
_source_authors <- o .: "author" -- _source_authors <- o .:? "author"
mPubDate <- o .:? "publicationDate" mPubDate <- o .:? "publicationDate"
pure $ Source { _source_publicationDate = parsePubDate mPubDate pure $ Source { _source_publicationDate = parsePubDate mPubDate
, .. } , .. }
...@@ -56,7 +56,7 @@ data Document = Document ...@@ -56,7 +56,7 @@ data Document = Document
, _document_authors :: [Author] , _document_authors :: [Author]
, _document_abstract :: Maybe T.Text , _document_abstract :: Maybe T.Text
, _document_publicationDate :: Maybe Int , _document_publicationDate :: Maybe Int
, _document_sources :: [Source] , _document_sources :: Source
} deriving (Show, Generic) } deriving (Show, Generic)
L.makeLenses ''Document L.makeLenses ''Document
...@@ -66,7 +66,7 @@ instance FromJSON Document where ...@@ -66,7 +66,7 @@ instance FromJSON Document where
_document_title <- o .:? "title" _document_title <- o .:? "title"
_document_authors <- o .: "author" <|> pure [] _document_authors <- o .: "author" <|> pure []
_document_abstract <- o .:? "abstract" _document_abstract <- o .:? "abstract"
_document_sources <- o .: "host" <|> pure [] _document_sources <- o .: "host"
mPubDate <- o .:? "publicationDate" mPubDate <- o .:? "publicationDate"
pure $ Document { _document_publicationDate = parsePubDate mPubDate, .. } pure $ Document { _document_publicationDate = parsePubDate mPubDate, .. }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment