From ebf65b1b78a6be6e1be7efd610d38d886ad85c87 Mon Sep 17 00:00:00 2001 From: Alexis Pentori Date: Tue, 16 Jan 2024 16:11:38 +0100 Subject: [PATCH] source-crypto-market-extractor: fix coin name not being correctly passed Signed-off-by: Alexis Pentori --- .../source_crypto_market_extractor/source.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/source-crypto-market-extractor/source_crypto_market_extractor/source.py b/source-crypto-market-extractor/source_crypto_market_extractor/source.py index 997c89e..ae1b7cf 100644 --- a/source-crypto-market-extractor/source_crypto_market_extractor/source.py +++ b/source-crypto-market-extractor/source_crypto_market_extractor/source.py @@ -16,7 +16,7 @@ logger = logging.getLogger("airbyte") class CoinPrice(HttpStream): url_base = 'https://api.coingecko.com/api/v3/coins/' - + primary_key = None def __init__(self, coins: List['str'], **kwargs): @@ -27,11 +27,10 @@ class CoinPrice(HttpStream): return None - def stream_slices(self, **kwargs) -> Iterable[Optional[Mapping[str, Any]]]: for coin in self.coins: yield { - "coin": coin, + "coin": coin } def path(self, stream_slice: Mapping[str, Any] = None, **kwargs) -> str: @@ -43,21 +42,21 @@ class CoinPrice(HttpStream): stream_slice: Mapping[str, Any] = None, **kwargs ) -> Iterable[Mapping]: - logger.info("Parsing Coin Gecko date for %s", stream_slice['coin']) + coin=stream_slice["coin"] + logger.info("Parsing Coin Gecko data for %s", coin) market_chart = response.json() yield { - "coin": stream_slices['coin'], + "coin": coin, "date": datetime.today().strftime('%Y%m%d_%H%M'), # The first value of the prices objects is weird "price": market_chart['prices'][1][1], } - # Source class SourceCryptoMarketExtractor(AbstractSource): def check_connection(self, logger, config) -> Tuple[bool, any]: return True, None def streams(self, config: Mapping[str, Any]) -> List[Stream]: - + logger.info('Config : %s', config['coins']) return [CoinPrice(coins=config['coins'])]