Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pindexer: dex-explorer: implement low high in summary #4931

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion crates/bin/pindexer/src/dex_ex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,9 @@ mod summary {
SELECT
COALESCE(SUM(direct_volume), 0.0) AS direct_volume_over_window,
COALESCE(SUM(swap_volume), 0.0) AS swap_volume_over_window,
COALESCE(SUM(trades), 0.0) AS trades_over_window
COALESCE(SUM(trades), 0.0) AS trades_over_window,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

N.B. if we moved these large queries to a discrete text file and used include_str on them, then we could lint them with sqlfluff cf. #4759 (comment). I tried on this specific error and the tool reported:

L:  40 | P:   5 |  PRS | Line 40, Position 5: Found unparsable section:
                       | 'COALESCE(MIN(price), 0.0) AS low,\n    CO...'

Not convinced that it's worth moving the queries out of the code just to aid a linter, though. I'd thought that sqlx would catch that syntax error at compile time, but no.

COALESCE(MIN(price), 0.0) AS low,
COALESCE(MAX(price), 0.0) AS high
FROM snapshots
WHERE time <= $3
AND time >= $4
Expand All @@ -452,6 +454,7 @@ mod summary {
SELECT
$1, $2, $5,
price, price_then,
low, high,
liquidity, liquidity_then,
direct_volume_over_window,
swap_volume_over_window,
Expand Down
2 changes: 2 additions & 0 deletions crates/bin/pindexer/src/dex_ex/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ CREATE TABLE IF NOT EXISTS dex_ex_pairs_summary (
the_window TEXT NOT NULL,
price FLOAT8 NOT NULL,
price_then FLOAT8 NOT NULL,
low FLOAT8 NOT NULL,
high FLOAT8 NOT NULL,
liquidity FLOAT8 NOT NULL,
liquidity_then FLOAT8 NOT NULL,
direct_volume_over_window FLOAT8 NOT NULL,
Expand Down
Loading