diff --git a/datasets/nfts/nfts/cli.py b/datasets/nfts/nfts/cli.py index ad04fce5..c0ae388f 100644 --- a/datasets/nfts/nfts/cli.py +++ b/datasets/nfts/nfts/cli.py @@ -69,12 +69,12 @@ def handle_materialize(args: argparse.Namespace) -> None: EthereumLabel if args.blockchain == Blockchain.ETHEREUM else PolygonLabel ) - print(label_model) - with yield_db_session_ctx() as db_session, contextlib.closing( sqlite3.connect(args.datastore) ) as moonstream_datastore: - last_saved_block = get_last_saved_block(moonstream_datastore, args.blockchain) + last_saved_block = get_last_saved_block( + moonstream_datastore, args.blockchain.value + ) logger.info(f"Last saved block: {last_saved_block}") if last_saved_block >= bounds.starting_block: logger.info( diff --git a/datasets/nfts/nfts/datastore.py b/datasets/nfts/nfts/datastore.py index 519844c9..db994957 100644 --- a/datasets/nfts/nfts/datastore.py +++ b/datasets/nfts/nfts/datastore.py @@ -389,10 +389,11 @@ def get_last_saved_block(conn: sqlite3.Connection, blockchain_type: str) -> int: query = f"SELECT MAX(blockNumber) FROM transactions WHERE blockchainType = '{blockchain_type}'" cur.execute(query) - if cur.fetchone()[0] is None: + result = cur.fetchone() + if result is None: return 0 - return cur.fetchone()[0] + return result[0] def setup_database(conn: sqlite3.Connection) -> None: