Skip to content

Commit

Permalink
Fix explorer summary histogram data order
Browse files Browse the repository at this point in the history
The histogram data returned by the `get_explorer_summary` endpoint is
returned in the wrong order.  The data is meant to be in the order of
ascending block height, but it is returned in descending block height
order.  This is due to the way we retrieve the last 50 blocks.

To fix this the query that retrieves the latest 50 blocks is changed slightly.
Using a sub-query, we can target the last 50 blocks, then re-sort the rows
based on the block height ascending to get the correct ordering.
  • Loading branch information
Ayiga committed May 23, 2024
1 parent 337df31 commit 6a6f0cf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/data_source/storage/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2219,8 +2219,10 @@ where
FROM header AS h
JOIN payload AS p ON
p.height = h.height
ORDER BY h.height DESC
LIMIT 50",
WHERE
h.height IN (SELECT height FROM header ORDER BY height DESC LIMIT 50)
ORDER BY h.height ASC
",
Vec::<Box<dyn ToSql + Send + Sync>>::new(),
).await?;

Expand Down

0 comments on commit 6a6f0cf

Please sign in to comment.