Skip to content

Commit

Permalink
return all oracles
Browse files Browse the repository at this point in the history
  • Loading branch information
nnn-gif committed Sep 21, 2023
1 parent 5fb36d8 commit 3ad20dc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
13 changes: 1 addition & 12 deletions cmd/http/oraclebuilder/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,19 +253,8 @@ func (ob *Env) Create(context *gin.Context) {
// List: list owner oracles
func (ob *Env) List(context *gin.Context) {
creator := context.Query("creator")
deleted := context.Query("deleted")
expired := context.Query("expired")

isDeleted, err := strconv.ParseBool(deleted)
if err != nil {
isDeleted = true
}
isExpired, err := strconv.ParseBool(expired)
if err != nil {
isExpired = true
}

oracles, err := ob.RelDB.GetOraclesByOwner(creator, isDeleted, isExpired)
oracles, err := ob.RelDB.GetOraclesByOwner(creator)
if err != nil {
log.Errorln("List Oracles: error on getOraclesByOwner ", err)
context.JSON(http.StatusInternalServerError, err)
Expand Down
5 changes: 2 additions & 3 deletions pkg/model/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func (rdb *RelDB) GetFeederResources() (addresses []string, err error) {

}

func (rdb *RelDB) GetOraclesByOwner(owner string, deleted, expired bool) (oracleconfigs []dia.OracleConfig, err error) {
func (rdb *RelDB) GetOraclesByOwner(owner string) (oracleconfigs []dia.OracleConfig, err error) {
var (
rows pgx.Rows
deviationFloat float64
Expand All @@ -250,13 +250,12 @@ func (rdb *RelDB) GetOraclesByOwner(owner string, deleted, expired bool) (oracle
ON t1.address = fu.oracle_address
AND t1.chainID = fu.chain_id
WHERE t1.owner = $1
AND t1.deleted = $2
GROUP BY
t1.address, t1.feeder_id, t1.owner, t1.symbols, t1.chainID,
t1.frequency, t1.sleepseconds, t1.deviationpermille, t1.blockchainnode, t1.active,
t1.mandatory_frequency, t1.feeder_address, t1.createddate, t1.feedselection,
t1.lastupdate, t1.expired,t1.expired_time;`, oracleconfigTable, feederupdatesTable)
rows, err = rdb.postgresClient.Query(context.Background(), query, owner, deleted)
rows, err = rdb.postgresClient.Query(context.Background(), query, owner)
if err != nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/relDB.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ type RelDatastore interface {
GetOracleConfig(address, chainid string) (oracleconfig dia.OracleConfig, err error)
ChangeOracleState(feederID string, active bool) (err error)
DeleteOracle(feederID string) (err error)
GetOraclesByOwner(owner string, deleted, expired bool) (oracleconfigs []dia.OracleConfig, err error)
GetOraclesByOwner(owner string) (oracleconfigs []dia.OracleConfig, err error)
GetAllFeeders(bool) (oracleconfigs []dia.OracleConfig, err error)
GetFeederResources() (addresses []string, err error)
GetOracleUpdates(address string, chainid string, offset int) ([]dia.OracleUpdate, error)
Expand Down

0 comments on commit 3ad20dc

Please sign in to comment.