Skip to content

Commit

Permalink
Fix: links count in global constants request (#948)
Browse files Browse the repository at this point in the history
* Fix: links count in global constants request

* Fix: empty response
  • Loading branch information
aopoltorzhicky authored Oct 20, 2022
1 parent 7ac21d1 commit e7a0f9f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/postgres/global_constant/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (storage *Storage) List(size, offset int64, orderBy, sort string) ([]contra

var constants []contract.ListGlobalConstantItem
_, err := storage.DB.Query(&constants,
`select global_constants.timestamp, global_constants.level, global_constants.address, count(contracts.babylon_id) as links_count from global_constants
`select global_constants.timestamp, global_constants.level, global_constants.address, count(contracts.id) as links_count from global_constants
left join script_constants as t on global_constants.id = t.global_constant_id
left join contracts on t.script_id = contracts.babylon_id or t.script_id = contracts.jakarta_id
group by global_constants.id
Expand All @@ -74,6 +74,9 @@ func (storage *Storage) List(size, offset int64, orderBy, sort string) ([]contra
if err != nil {
return nil, err
}
if len(constants) == 0 {
constants = make([]contract.ListGlobalConstantItem, 0)
}

return constants, nil

Expand Down

0 comments on commit e7a0f9f

Please sign in to comment.