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