Commit 871b5b0a authored by szh's avatar szh

add count

parent 0f9d2196
......@@ -30,8 +30,8 @@ func ExistByAddrHeight(addr string,height int64) (bool, error) {
}
// GetAddrTotal gets the total number of addr based on the constraints
func GetMinerTxsTotal(addr string) (int, error) {
var count int
func GetMinerTxsTotal(addr string) (int64, error) {
var count int64
if err := db.Model(&RaspMinerTxs{}).Where("miner = ? ",addr).Count(&count).Error; err != nil {
return 0, err
}
......
......@@ -37,6 +37,7 @@ type MinedInfo struct {
MinerEndTime int64 `json:"miner_end_time"`
ServeTime int64 `json:"serve_time"`
MinedList []*MinedTxInfo `json:"mined_list"`
MinedTotal int64 `json:"mined_total"`
}
type MinedTxInfo struct {
......@@ -167,6 +168,10 @@ func (p *Pai) GetTicketInfo(req *ReqTicketInfo) (*MinedInfo,error) {
return nil,err
}
if req.Detail {
count,err := models.GetMinerTxsTotal(req.Addr)
if err != nil {
logging.Error("models.GetMinerTxsCount err",err)
}
txs,err := models.GetMinerTxs(req.Page,req.Pagesize,map[string]interface{}{"miner":req.Addr})
if err != nil {
logging.Error("models.GetAddrs err",err)
......@@ -180,6 +185,7 @@ func (p *Pai) GetTicketInfo(req *ReqTicketInfo) (*MinedInfo,error) {
t.Hash = v.Hash
txsList = append(txsList,&t)
}
info.MinedTotal = count
}
info.MinedAmount = stat.MinedAmount
info.MinedTicketCount = stat.MinedTicketCount
......@@ -188,5 +194,6 @@ func (p *Pai) GetTicketInfo(req *ReqTicketInfo) (*MinedInfo,error) {
info.MinerEndTime = stat.MinerEndTime
info.ServeTime = time.Now().Unix()
info.MinedList = txsList
return &info,nil
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment