Skip to content

Commit

Permalink
Fix: OPG query
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Jul 10, 2023
1 parent b1e513e commit 7258f27
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions internal/postgres/operation/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ func (storage *Storage) OPG(address string, size, lastID int64) ([]operation.OPG
ta.status,
ta.counter,
ta.kind,
ta.hash,
ta.level,
ta.timestamp,
ta.entrypoint,
ta.content_index,
(select sum(case when source_id = ?1 then -"amount" else "amount" end) as "flow"
from operations
where hash = ta.hash and counter = ta.counter and (timestamp < ?4) and (timestamp >= ?3)
Expand All @@ -318,12 +323,7 @@ func (storage *Storage) OPG(address string, size, lastID int64) ([]operation.OPG
(select sum("burned") + sum("fee") as total_cost
from operations
where hash = ta.hash and counter = ta.counter and (timestamp < ?4) and (timestamp >= ?3)
),
ta.hash,
ta.level,
ta.timestamp,
ta.entrypoint,
ta.content_index
)
from (
select
min(id) as last_id,
Expand Down Expand Up @@ -353,6 +353,8 @@ func (storage *Storage) OPG(address string, size, lastID int64) ([]operation.OPG
break
}
}

end = len(result) == limit
}

return result, nil
Expand Down

0 comments on commit 7258f27

Please sign in to comment.