Commit 8d844d13 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[pubmed] use the upstream pubmed version, with reader monad

parent bc39f7dc
Pipeline #3428 passed with stage
in 92 minutes and 23 seconds
...@@ -14,6 +14,7 @@ module Gargantext.Core.Text.Corpus.API.Pubmed ...@@ -14,6 +14,7 @@ module Gargantext.Core.Text.Corpus.API.Pubmed
where where
import Conduit import Conduit
import Control.Monad.Reader (runReaderT)
import Data.Either (Either) import Data.Either (Either)
import Data.Maybe import Data.Maybe
import Data.Text (Text) import Data.Text (Text)
...@@ -30,7 +31,7 @@ import PUBMED.Types (Config(..)) ...@@ -30,7 +31,7 @@ import PUBMED.Types (Config(..))
type Query = Text type Query = Text
type Limit = PubMed.Limit type Limit = Integer
-- | TODO put default pubmed query in gargantext.ini -- | TODO put default pubmed query in gargantext.ini
...@@ -40,8 +41,13 @@ get :: Maybe Text ...@@ -40,8 +41,13 @@ get :: Maybe Text
-> Maybe Limit -> Maybe Limit
-> IO (Either ClientError (Maybe Integer, ConduitT () HyperdataDocument IO ())) -> IO (Either ClientError (Maybe Integer, ConduitT () HyperdataDocument IO ()))
get mAPIKey q l = do get mAPIKey q l = do
eRes <- PubMed.getMetadataWithC (Config { mAPIKey = mAPIKey }) q l eRes <- runReaderT PubMed.getMetadataWithC (Config { apiKey = mAPIKey
pure $ (\(len, docsC) -> (len, docsC .| mapC (toDoc EN))) <$> eRes , query = q
, perPage = Nothing })
let takeLimit = case l of
Nothing -> mapC identity
Just l' -> takeC $ fromIntegral l'
pure $ (\(len, docsC) -> (len, docsC .| takeLimit .| mapC (toDoc EN))) <$> eRes
--either (\e -> panic $ "CRAWL: PubMed" <> e) (map (toDoc EN)) --either (\e -> panic $ "CRAWL: PubMed" <> e) (map (toDoc EN))
-- <$> PubMed.getMetadataWithC q l -- <$> PubMed.getMetadataWithC q l
......
...@@ -74,7 +74,7 @@ extra-deps: ...@@ -74,7 +74,7 @@ extra-deps:
# External Data API connectors # External Data API connectors
- git: https://gitlab.iscpif.fr/gargantext/crawlers/pubmed.git - git: https://gitlab.iscpif.fr/gargantext/crawlers/pubmed.git
commit: b78bdc85c222019d1eb6c7959b175d76f70532f1 commit: 31cb4d28dcb5d17274cede5e67b2a01914379129
#commit: 364885c891cbadcd4d8a623d2e41394b09f653aa #commit: 364885c891cbadcd4d8a623d2e41394b09f653aa
- git: https://gitlab.iscpif.fr/gargantext/crawlers/istex.git - git: https://gitlab.iscpif.fr/gargantext/crawlers/istex.git
commit: a34bb341236d82cf3d488210bc1d8448a98f5808 commit: a34bb341236d82cf3d488210bc1d8448a98f5808
......
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