Skip to content

Commit

Permalink
deleting entries fixes if script restarts
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhagarwal03 committed Aug 13, 2024
1 parent e89681f commit ea28651
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Empty file added raw_token_imbalances.log
Empty file.
4 changes: 2 additions & 2 deletions src/sql/delete_entries_max_block.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ BEGIN;

DELETE FROM raw_token_imbalances
WHERE chain_name = :chain_name
AND block_number = :block_number;
AND block_number >= :block_number;

DELETE FROM slippage_prices
WHERE chain_name = :chain_name
AND block_number = :block_number;
AND block_number >= :block_number;

COMMIT;
13 changes: 11 additions & 2 deletions src/sql/select_max_block.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
SELECT MAX(block_number) FROM raw_token_imbalances
WHERE chain_name = :chain_name;
SELECT
MIN(max_block_number) AS min_max_block_number
FROM (
SELECT MAX(block_number) AS max_block_number
FROM raw_token_imbalances
WHERE chain_name = :chain_name
UNION ALL
SELECT MAX(block_number) AS max_block_number
FROM slippage_prices
WHERE chain_name = :chain_name
) AS max_blocks;

0 comments on commit ea28651

Please sign in to comment.