Skip to content

Commit

Permalink
fix getBlockInfoList
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobeyw committed Apr 29, 2024
1 parent d2027fe commit 7dece7f
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions neo3fura_http/biz/api/src.GetBlockInfoList.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package api
import (
"encoding/json"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
)

func (me *T) GetBlockInfoList(args struct {
Expand Down Expand Up @@ -46,21 +45,13 @@ func (me *T) GetBlockInfoList(args struct {
//bson.M{"$project": bson.M{"transactioncount": bson.M{"$cond": bson.M{"if": bson.M{"$gt": []interface{}{"$info", []interface{}{}}}, "then": bson.M{"$arrayElemAt": []interface{}{"$info.count", 0}}, "else": 0}},
// "_id": 1, "index": 1, "size": 1, "timestamp": 1, "hash": 1}},

bson.M{"$project": bson.M{"info": 1, "_id": 1, "index": 1, "size": 1, "timestamp": 1, "hash": 1}},
bson.M{"$project": bson.M{"_id": 1, "index": 1, "size": 1, "timestamp": 1, "hash": 1, "transactioncount": bson.M{"$size": "$info"}}},

bson.M{"$limit": args.Limit},
bson.M{"$skip": args.Skip},
bson.M{"$limit": args.Limit},
},
Query: []string{}}, ret)

for _, item := range r1 {
info := item["info"]
item["transactioncount"] = 0
if info != nil {
item["transactioncount"] = len(info.(primitive.A))
}
delete(item, "info")
}
count, err := me.Client.QueryDocument(struct {
Collection string
Index string
Expand Down

0 comments on commit 7dece7f

Please sign in to comment.