Commit a9d8e08a authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] bug in number of returned document (Right a <> Right b = Right a insead of Right (a <> b))

parent 4cf5fa03
...@@ -24,6 +24,7 @@ import Data.Attoparsec.ByteString.Char8 (anyChar) ...@@ -24,6 +24,7 @@ import Data.Attoparsec.ByteString.Char8 (anyChar)
import qualified Data.ByteString.Lazy as LBS import qualified Data.ByteString.Lazy as LBS
import qualified Data.ByteString as DB import qualified Data.ByteString as DB
import qualified Data.Text as T import qualified Data.Text as T
import qualified Data.List as List
-- | API main function -- | API main function
getMetadataWith :: Text -> Maybe Limit -> IO (Either Text [PubMed]) getMetadataWith :: Text -> Maybe Limit -> IO (Either Text [PubMed])
...@@ -56,11 +57,16 @@ type Limit = Integer ...@@ -56,11 +57,16 @@ type Limit = Integer
runMultipleFPAR :: [Integer] runMultipleFPAR :: [Integer]
-> IO (Either Text [PubMed]) -> IO (Either Text [PubMed])
runMultipleFPAR ids runMultipleFPAR ids = List.foldl1' concat'
| length ids < 300 = runSimpleFetchPubmedAbstractRequest ids <$> mapM runSimpleFetchPubmedAbstractRequest (by 300 ids)
| otherwise = do where
runSimpleFetchPubmedAbstractRequest (Prelude.take 300 ids) by _ [] = []
<> runMultipleFPAR (drop 300 ids) by n ns = head' : ( by n tail')
where
(head',tail') = List.splitAt n ns
concat' (Right n) (Right m) = Right $ n <> m
concat' n m = n <> m
runSimpleFetchPubmedAbstractRequest :: runSimpleFetchPubmedAbstractRequest ::
[Integer] [Integer]
......
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