Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP INDEX idx_block_timestamp;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE INDEX idx_block_timestamp ON blocks(timestamp);
3 changes: 3 additions & 0 deletions webserver/src/repository/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ impl BlockRepositoryTrait for BlockRepository {
.expect("Invalid timestamp")
.naive_utc();

let lower_bound = timestamp - chrono::Duration::seconds(60);

conn.interact(move |conn| {
blocks::table
.filter(blocks::timestamp.ge(lower_bound))
.filter(blocks::timestamp.le(timestamp))
.order(blocks::timestamp.desc())
.select(BlockDb::as_select())
Expand Down