source-crypto-market-extractor: fix coin name not being correctly passed

Signed-off-by: Alexis Pentori <alexis@status.im>
This commit is contained in:
Alexis Pentori 2024-01-16 16:11:38 +01:00
parent e1257ad5ff
commit ebf65b1b78
No known key found for this signature in database
GPG Key ID: 65250D2801E47A10
1 changed files with 6 additions and 7 deletions

View File

@ -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'])]