From 7dece7fc40c4ffedf1a119ed656ab77db53f5fb1 Mon Sep 17 00:00:00 2001 From: Tobeyw Date: Mon, 29 Apr 2024 17:03:27 +0800 Subject: [PATCH] fix getBlockInfoList --- neo3fura_http/biz/api/src.GetBlockInfoList.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/neo3fura_http/biz/api/src.GetBlockInfoList.go b/neo3fura_http/biz/api/src.GetBlockInfoList.go index 08a3bc4..27d2a1a 100644 --- a/neo3fura_http/biz/api/src.GetBlockInfoList.go +++ b/neo3fura_http/biz/api/src.GetBlockInfoList.go @@ -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 { @@ -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