diff --git a/api.go b/api.go index 296e323..9f26b76 100644 --- a/api.go +++ b/api.go @@ -734,8 +734,13 @@ func (s *Arseeding) getOrders(c *gin.Context) { errorResponse(c, err.Error()) return } - num := 200 - orders, err := s.wdb.GetOrdersBySigner(signerAddr, cursorId, num) + num, err := strconv.ParseInt(c.DefaultQuery("num", "20"), 10, 64) + if err != nil { + errorResponse(c, err.Error()) + return + } + + orders, err := s.wdb.GetOrdersBySigner(signerAddr, cursorId, int(num)) if err != nil { internalErrorResponse(c, err.Error()) return diff --git a/schema/db.go b/schema/db.go index d2fc318..b00f451 100644 --- a/schema/db.go +++ b/schema/db.go @@ -46,7 +46,7 @@ type Order struct { PaymentStatus string `gorm:"index:idx0" json:"paymentStatus"` // "unpaid", "paid", "expired" PaymentId string `json:"paymentId"` // everHash - OnChainStatus string `json:"onChainStatus"` // "waiting","pending","success","failed" + OnChainStatus string `gorm:"index:idx5" json:"onChainStatus"` // "waiting","pending","success","failed" ApiKey string `gorm:"index:idx2" json:"-"` Sort bool `json:"sort"` // upload items to arweave by sequence } diff --git a/wdb.go b/wdb.go index 2bc7e28..1011a43 100644 --- a/wdb.go +++ b/wdb.go @@ -146,7 +146,7 @@ func (w *Wdb) GetOrdersBySigner(signer string, cursorId int64, num int) ([]schem cursorId = math.MaxInt64 } records := make([]schema.Order, 0, num) - err := w.Db.Model(&schema.Order{}).Where("signer = ? and id < ?", signer, cursorId).Order("id DESC").Limit(num).Find(&records).Error + err := w.Db.Model(&schema.Order{}).Where("id < ? and signer = ? and on_chain_status != ?", cursorId, signer, schema.FailedOnChain).Order("id DESC").Limit(num).Find(&records).Error return records, err }