Skip to content

Commit

Permalink
unused sql queries deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmenendez committed Sep 22, 2023
1 parent 21eff32 commit da58bc9
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 1,139 deletions.
24 changes: 0 additions & 24 deletions db/queries/blocks.sql
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
-- name: ListBlocks :many
SELECT * FROM blocks
ORDER BY id;

-- name: BlockByID :one
SELECT * FROM blocks
WHERE id = ?
LIMIT 1;

-- name: BlockByTimestamp :one
SELECT * FROM blocks
WHERE timestamp = ?
LIMIT 1;

-- name: BlockByRootHash :one
SELECT * FROM blocks
WHERE root_hash = ?
LIMIT 1;

-- name: CreateBlock :execresult
INSERT INTO blocks (
id,
Expand All @@ -27,16 +13,6 @@ VALUES (
?, ?, ?
);

-- name: DeleteBlock :execresult
DELETE FROM blocks
WHERE id = ?;

-- name: UpdateBlock :execresult
UPDATE blocks
SET timestamp = sqlc.arg(timestamp),
root_hash = sqlc.arg(root_hash)
WHERE id = sqlc.arg(id);

-- name: LastBlock :one
SELECT id FROM blocks
ORDER BY id DESC
Expand Down
51 changes: 1 addition & 50 deletions db/queries/censuses.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
-- name: ListCensuses :many
SELECT * FROM censuses
ORDER BY id;

-- name: CensusByID :one
SELECT * FROM censuses
WHERE id = ?
Expand All @@ -11,39 +7,6 @@ LIMIT 1;
SELECT * FROM censuses
WHERE strategy_id = ?;

-- name: CensusByMerkleRoot :one
SELECT * FROM censuses
WHERE merkle_root = ?
LIMIT 1;

-- name: CensusByQueueID :one
SELECT * FROM censuses
WHERE queue_id = ?
LIMIT 1;

-- name: CensusByURI :one
SELECT * FROM censuses
WHERE uri = ?
LIMIT 1;

-- name: CensusesByTokenID :many
SELECT c.* FROM censuses AS c
JOIN strategy_tokens AS st ON c.strategy_id = st.strategy_id
WHERE st.token_id = sqlc.arg(token_id)
LIMIT ? OFFSET ?;

-- name: CensusesByTokenType :many
SELECT c.* FROM censuses AS c
JOIN strategy_tokens AS st ON c.strategy_id = st.strategy_id
JOIN tokens AS t ON st.token_id = t.id
JOIN token_types AS tt ON t.type_id = tt.id
WHERE tt.type_name = ?;

-- name: LastCensusID :one
SELECT id
FROM censuses
ORDER BY id DESC
LIMIT 1;

-- name: CreateCensus :execresult
INSERT INTO censuses (
Expand All @@ -58,16 +21,4 @@ INSERT INTO censuses (
)
VALUES (
?, ?, ?, ?, ?, ?, ?, ?
);

-- name: DeleteCensus :execresult
DELETE FROM censuses
WHERE id = ?;

-- name: UpdateCensus :execresult
UPDATE censuses
SET merkle_root = sqlc.arg(merkle_root),
uri = sqlc.arg(uri),
size = sqlc.arg(size),
weight = sqlc.arg(weight)
WHERE id = sqlc.arg(id);
);
47 changes: 0 additions & 47 deletions db/queries/holders.sql
Original file line number Diff line number Diff line change
@@ -1,60 +1,19 @@
-- name: ListHolders :many
SELECT * FROM holders
ORDER BY id;

-- name: HolderByID :one
SELECT * FROM holders
WHERE id = ?
LIMIT 1;

-- name: CreateHolder :execresult
INSERT INTO holders (id)
VALUES (?);

-- name: DeleteHolder :execresult
DELETE FROM holders
WHERE id = ?;

-- name: ListTokenHolders :many
SELECT * FROM token_holders
ORDER BY token_id, holder_id, block_id;

-- name: TokensByHolderID :many
SELECT tokens.*
FROM Tokens
JOIN token_holders ON tokens.id = token_holders.token_id
WHERE token_holders.holder_id = ?;

-- name: TokensByHolderIDAndBlockID :many
SELECT tokens.*
FROM Tokens
JOIN token_holders ON tokens.id = token_holders.token_id
WHERE token_holders.holder_id = ? AND token_holders.block_id = ?;

-- name: TokenHoldersByTokenID :many
SELECT holders.*, token_holders.balance
FROM holders
JOIN token_holders ON holders.id = token_holders.holder_id
WHERE token_holders.token_id = ?;

-- name: TokenHoldersByTokenIDAndBlockID :many
SELECT holders.*
FROM holders
JOIN token_holders ON holders.id = token_holders.holder_id
WHERE token_holders.token_id = ? AND token_holders.block_id = ?;

-- name: TokenHoldersByTokenIDAndMinBalance :many
SELECT holders.*
FROM holders
JOIN token_holders ON holders.id = token_holders.holder_id
WHERE token_holders.token_id = ? AND token_holders.balance >= ?;

-- name: TokenHoldersByTokenIDAndBlockIDAndMinBalance :many
SELECT holders.*
FROM holders
JOIN token_holders ON holders.id = token_holders.holder_id
WHERE token_holders.token_id = ? AND token_holders.balance >= ? AND token_holders.block_id = ?;

-- name: TokenHolderByTokenIDAndHolderID :one
SELECT holders.*, token_holders.*
FROM holders
Expand All @@ -63,12 +22,6 @@ WHERE token_holders.token_id = ?
AND token_holders.chain_id = ?
AND token_holders.holder_id = ?;

-- name: TokenHolderByTokenIDAndBlockIDAndHolderID :one
SELECT holders.*, token_holders.balance
FROM holders
JOIN token_holders ON holders.id = token_holders.holder_id
WHERE token_holders.token_id = ? AND token_holders.holder_id = ? AND token_holders.block_id = ?;

-- name: LastBlockByTokenID :one
SELECT block_id
FROM token_holders
Expand Down
36 changes: 1 addition & 35 deletions db/queries/strategies.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ SELECT * FROM strategies
WHERE id = ?
LIMIT 1;

-- name: StrategyByPredicate :one
SELECT * FROM strategies
WHERE predicate = ?
LIMIT 1;

-- name: StrategiesByTokenID :many
SELECT s.* FROM strategies s
JOIN strategy_tokens st ON st.strategy_id = s.id
Expand All @@ -22,15 +17,6 @@ ORDER BY s.id;
INSERT INTO strategies (alias, predicate)
VALUES (?, ?);

-- name: UpdateStrategy :execresult
UPDATE strategies
SET predicate = sqlc.arg(predicate)
WHERE id = sqlc.arg(id);

-- name: DeleteStrategy :execresult
DELETE FROM strategies
WHERE id = ?;

-- name: CreateStrategyToken :execresult
INSERT INTO strategy_tokens (
strategy_id,
Expand All @@ -42,15 +28,6 @@ VALUES (
?, ?, ?, ?
);

-- name: UpdateStrategyToken :execresult
UPDATE strategy_tokens
SET min_balance = sqlc.arg(min_balance)
WHERE strategy_id = sqlc.arg(strategy_id) AND token_id = sqlc.arg(token_id);

-- name: DeleteStrategyToken :execresult
DELETE FROM strategy_tokens
WHERE strategy_id = ? AND token_id = ?;

-- name: StrategyTokens :many
SELECT *
FROM strategy_tokens
Expand All @@ -61,15 +38,4 @@ SELECT st.*, t.symbol
FROM strategy_tokens st
JOIN tokens t ON t.ID = st.token_id
WHERE strategy_id = ?
ORDER BY strategy_id, token_id;

-- name: StrategyTokenByStrategyIDAndTokenID :one
SELECT *
FROM strategy_tokens
WHERE strategy_id = ? AND token_id = ?
LIMIT 1;

-- name: StrategyTokenByStrategyIDAndTokenIDAndMethodHash :one
SELECT *
FROM strategy_tokens
WHERE strategy_id = ? AND token_id = ?;
ORDER BY strategy_id, token_id;
26 changes: 0 additions & 26 deletions db/queries/tokenTypes.sql

This file was deleted.

31 changes: 0 additions & 31 deletions db/queries/tokens.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,6 @@ SELECT * FROM tokens
WHERE id = ?
LIMIT 1;

-- name: TokenByName :one
SELECT * FROM tokens
WHERE name = ?
LIMIT 1;

-- name: TokenBySymbol :one
SELECT * FROM tokens
WHERE symbol = ?
LIMIT 1;

-- name: TokensByType :many
SELECT * FROM tokens
WHERE type_id = ?
ORDER BY name;

-- name: TokensByStrategyID :many
SELECT t.*, st.* FROM tokens t
JOIN strategy_tokens st ON st.token_id = t.id
Expand All @@ -45,18 +30,6 @@ VALUES (
?, ?, ?, ?, ?, ?, ?, ?, ?, ?
);

-- name: UpdateToken :execresult
UPDATE tokens
SET name = sqlc.arg(name),
symbol = sqlc.arg(symbol),
decimals = sqlc.arg(decimals),
total_supply = sqlc.arg(total_supply),
creation_block = sqlc.arg(creation_block),
type_id = sqlc.arg(type_id),
synced = sqlc.arg(synced),
tags = sqlc.arg(tags)
WHERE id = sqlc.arg(id);

-- name: UpdateTokenStatus :execresult
UPDATE tokens
SET synced = sqlc.arg(synced)
Expand All @@ -67,10 +40,6 @@ UPDATE tokens
SET creation_block = sqlc.arg(creation_block)
WHERE id = sqlc.arg(id);

-- name: DeleteToken :execresult
DELETE FROM tokens
WHERE id = ?;

-- name: ExistsToken :one
SELECT EXISTS
(SELECT id
Expand Down
Loading

0 comments on commit da58bc9

Please sign in to comment.