From 8744893f3daedaaf2cc5882eee0f84161cfc14eb Mon Sep 17 00:00:00 2001 From: harisang Date: Fri, 13 Dec 2024 15:03:51 +0200 Subject: [PATCH] small fixes --- queries/orderbook/barn_batch_rewards.sql | 2 +- queries/orderbook/create_batch_table.sql | 18 ------------------ queries/orderbook/prod_batch_rewards.sql | 2 +- src/data_sync/sync_data.py | 24 +----------------------- 4 files changed, 3 insertions(+), 43 deletions(-) delete mode 100644 queries/orderbook/create_batch_table.sql diff --git a/queries/orderbook/barn_batch_rewards.sql b/queries/orderbook/barn_batch_rewards.sql index 4d63ac3b..ea71b41d 100644 --- a/queries/orderbook/barn_batch_rewards.sql +++ b/queries/orderbook/barn_batch_rewards.sql @@ -214,7 +214,7 @@ dune_sync_batch_data_table as ( --noqa: ST03 when tx_hash is null then null else concat('0x', encode(tx_hash, 'hex')) end as tx_hash, - solver, + concat('0x', encode(solver, 'hex')) as solver, execution_cost, surplus, protocol_fee, diff --git a/queries/orderbook/create_batch_table.sql b/queries/orderbook/create_batch_table.sql deleted file mode 100644 index 069440c4..00000000 --- a/queries/orderbook/create_batch_table.sql +++ /dev/null @@ -1,18 +0,0 @@ --- sample table for creating the intermediate tables used in the analytics db to store batch data -create table if not exists table_name ( - environment varchar(6) not null, - auction_id bigint not null, - block_number bigint, - block_deadline bigint not null, - tx_hash bytea, - solver bytea not null, - execution_cost numeric(78, 0), - surplus numeric(78, 0), - protocol_fee numeric(78, 0), - network_fee numeric(78, 0), - uncapped_payment_native_token numeric(78, 0) not null, - capped_payment numeric(78, 0) not null, - winning_score numeric(78, 0) not null, - reference_score numeric(78, 0) not null, - primary key (block_deadline, auction_id, environment) -); diff --git a/queries/orderbook/prod_batch_rewards.sql b/queries/orderbook/prod_batch_rewards.sql index 0ff06a85..b3d70c51 100644 --- a/queries/orderbook/prod_batch_rewards.sql +++ b/queries/orderbook/prod_batch_rewards.sql @@ -214,7 +214,7 @@ dune_sync_batch_data_table as ( --noqa: ST03 when tx_hash is null then null else concat('0x', encode(tx_hash, 'hex')) end as tx_hash, - solver, + concat('0x', encode(solver, 'hex')) as solver, execution_cost, surplus, protocol_fee, diff --git a/src/data_sync/sync_data.py b/src/data_sync/sync_data.py index 7cb69e2b..ed8747cd 100644 --- a/src/data_sync/sync_data.py +++ b/src/data_sync/sync_data.py @@ -54,9 +54,7 @@ async def sync_data_to_db( # pylint: disable=too-many-arguments ) # we note that the block range computed above is meant to be interpreted as # a closed interval - for i, _ in enumerate(block_range_list): - start_block = block_range_list[i][0] - end_block = block_range_list[i][1] + for i, (start_block, end_block) in enumerate(block_range_list): network_name = "ethereum" if network == "mainnet" else network table_name = type_of_data + "_data_" + network_name + "_" + months_list[i] block_range = BlockRange(block_from=start_block, block_to=end_block) @@ -69,26 +67,6 @@ async def sync_data_to_db( # pylint: disable=too-many-arguments data = orderbook.get_order_data(block_range, config) log.info("SQL query successfully executed. About to update analytics table.") - # ############### - # # we first create the corresponding table in case it does not exist yet. - # analytics_engine = OrderbookFetcher.pg_engine(OrderbookEnv.ANALYTICS) - # if type_of_data == "batch": - # sql_file_path = "queries/orderbook/create_batch_table.sql" - # else: - # sql_file_path = "queries/orderbook/create_order_table.sql" - # with open(sql_file_path, "r") as file: - # sql_commands_prelim = file.read() - # sql_commands = sql_commands_prelim.replace("table_name", table_name) - # print(sql_commands) - # # Connect to the database and execute the command - # # Execute the SQL commands - # with analytics_engine.connect() as connection: - # for statement in sql_commands.split(";"): # Split commands by semicolon - # statement = statement.strip() - # if statement: # Skip empty statements - # connection.execute(text(statement)) - # ############### - data.to_sql( table_name, OrderbookFetcher.pg_engine(OrderbookEnv.ANALYTICS),