Skip to content

Commit

Permalink
Add atomic txs to aggregates count
Browse files Browse the repository at this point in the history
  • Loading branch information
charalarg committed Feb 2, 2023
1 parent d6e0b81 commit 88860af
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions caching/aggregates_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"net/url"
"time"

"github.com/chain4travel/magellan/db"

"github.com/chain4travel/magellan/cfg"
"github.com/chain4travel/magellan/models"
"github.com/chain4travel/magellan/services/indexes/params"
Expand Down Expand Up @@ -221,12 +223,17 @@ func (ac *aggregatesCache) GetAggregatesAndUpdate(chains map[string]cfg.Chain, c
}

// 3rd step: we obtain the count of the transactions based on the block range we acquired from the previous steps
// we will construct based on the block numbers the relevant block_idx filters since this is our main index in the cvm_transactions_txdata table
// we will construct based on the block numbers the relevant block_idx filters since this is our main index
// in the cvm_transactions_txdata and cvm_transactions_atomic tables
union := dbr.Union(
dbRunner.Select("block_idx").From(db.TableCvmTransactionsTxdata),
dbRunner.Select("block_idx").From(db.TableCvmTransactionsAtomic),
).As("union_q")
builder = dbRunner.
Select("count(*) as transaction_count").
From("cvm_transactions_txdata").
Where("cvm_transactions_txdata.block_idx >= concat(?,'000')", firstBlockValue.Block).
Where("cvm_transactions_txdata.block_idx <= concat(?,'999')", lastBlockValue.Block)
Select("count(*) as transaction_count").
From(union).
Where("union_q.block_idx >= concat(?,'000')", firstBlockValue.Block).
Where("union_q.block_idx <= concat(?,'999')", lastBlockValue.Block)

cvmIntervals := models.AggregatesList{}

Expand Down

0 comments on commit 88860af

Please sign in to comment.