Skip to content

Commit

Permalink
Fix: get last_action for contract from database
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Jul 11, 2023
1 parent 8306993 commit 9c33c53
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions internal/postgres/operation/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,20 @@ func (storage *Storage) ContractStats(address string) (stats operation.ContractS
return
}

var result lastTimestampResult
if _, err := storage.DB.QueryOne(&result, cteContractStatsTemplate, accountID, accountID); err != nil {
return stats, err
if bcd.IsContractLazy(address) {
if err := storage.DB.Model((*contract.Contract)(nil)).
Column("last_action").
Where("account_id = ?", accountID).
Select(&stats.LastAction); err != nil {
return stats, err
}
} else {
var result lastTimestampResult
if _, err := storage.DB.QueryOne(&result, cteContractStatsTemplate, accountID, accountID); err != nil {
return stats, err
}
stats.LastAction = result.Timestamp
}
stats.LastAction = result.Timestamp

count, err := storage.DB.Model((*operation.Operation)(nil)).WhereGroup(
func(q *orm.Query) (*orm.Query, error) {
Expand Down

0 comments on commit 9c33c53

Please sign in to comment.