Commit 02e03d9b authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[conduit] fixes to conduit query

limit was set incorrectly
parent ba743a17
......@@ -10,6 +10,7 @@ import Data.Maybe (fromMaybe)
import Data.Text (Text)
import Network.HTTP.Client (newManager)
import Network.HTTP.Client.TLS (tlsManagerSettings)
import Panic (panic)
import PUBMED.Client
import PUBMED.Parser
import Prelude hiding (takeWhile)
......@@ -28,7 +29,7 @@ pmPort :: Int
pmPort = 443
batchSize :: Int
batchSize = 2000
batchSize = 200
defaultEnv :: IO ClientEnv
defaultEnv = do
......@@ -56,13 +57,13 @@ getMetadataWithC query limit = do
numResults = fromMaybe 0 $ parseDocCount $ TL.fromStrict $ TE.decodeUtf8 $ LBS.toStrict res
numPages = numResults `div` (fromIntegral perPage) + 1
getPage :: ClientEnv -> Text -> Int -> Int -> IO [PubMed]
getPage env q perPage pageNum = do
let offset = fromIntegral $ pageNum * perPage
eDocs <- runSimpleFindPubmedAbstractRequest q (Just offset) (Just $ fromIntegral pageNum)
pure $ case eDocs of
Left err -> []
Right docs -> docs
getPage :: ClientEnv -> Text -> Int -> Int -> IO [PubMed]
getPage env q perPage pageNum = do
let offset = fromIntegral $ pageNum * perPage
eDocs <- runSimpleFindPubmedAbstractRequest q (Just offset) (Just $ fromIntegral perPage)
pure $ case eDocs of
Left err -> panic $ "[getPage] error: " <> show err
Right docs -> docs
-- | TODO this parser need at least one subs at the end
-- (use endOfInput)
......
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