source-crypto-market-extractor: fix coin name not being correctly passed
Signed-off-by: Alexis Pentori <alexis@status.im>
This commit is contained in:
parent
e1257ad5ff
commit
ebf65b1b78
|
@ -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'])]
|
||||
|
|
Loading…
Reference in New Issue