Skip to content

Commit

Permalink
fix maxLimit
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobeyw committed Jul 18, 2024
1 parent 44581f7 commit c3747c9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
44 changes: 26 additions & 18 deletions neo3fura_http/biz/api/src.GetAssetInfos.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package api
import (
"encoding/json"
"fmt"

"neo3fura_http/lib/type/h160"
"neo3fura_http/lib/type/strval"
"neo3fura_http/var/stderr"
Expand Down Expand Up @@ -39,7 +40,12 @@ func (me *T) GetAssetInfos(args struct {
f = bson.M{"$or": addresses}
}
}
r1, _, err := me.Client.QueryAll(struct {

if args.Standard == "NEP17" || args.Standard == "NEP11" {
f["type"] = args.Standard.Val()
}

r1, count, err := me.Client.QueryAll(struct {
Collection string
Index string
Sort bson.M
Expand All @@ -57,6 +63,8 @@ func (me *T) GetAssetInfos(args struct {
if err != nil {
return err
}

fmt.Println("count:", count)
// retrieve all tokens
r2, err := me.Client.QueryLastJob(struct{ Collection string }{Collection: "PopularTokens"})
if err != nil {
Expand Down Expand Up @@ -127,23 +135,23 @@ func (me *T) GetAssetInfos(args struct {
}
}

r5 := make([]map[string]interface{}, 0)
r6 := make([]map[string]interface{}, 0)
for _, item := range r1 {
if args.Standard == "" || (args.Standard == "NEP11" && item["type"] == "NEP11") || (args.Standard == "NEP17" && item["type"] == "NEP17") {
r5 = append(r5, item)
}
}
for i, item := range r5 {
if int64(i) < args.Skip {
continue
} else if int64(i) > args.Skip+args.Limit-1 {
continue
} else {
r6 = append(r6, item)
}
}
r4, err := me.FilterArrayAndAppendCount(r6, int64(len(r5)), args.Filter)
//r5 := make([]map[string]interface{}, 0)
//r6 := make([]map[string]interface{}, 0)
//for _, item := range r1 {
// if args.Standard == "" || (args.Standard == "NEP11" && item["type"] == "NEP11") || (args.Standard == "NEP17" && item["type"] == "NEP17") {
// r5 = append(r5, item)
// }
//}
//for i, item := range r5 {
// if int64(i) < args.Skip {
// continue
// } else if int64(i) > args.Skip+args.Limit-1 {
// continue
// } else {
// //r6 = append(r6, item)
// }
//}
r4, err := me.FilterArrayAndAppendCount(r1, count, args.Filter)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion neo3fura_http/lib/type/consts/src.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ const (
NEO = "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5"
GAS = "0xd2a4cff31913016155e38e474a2c06d08be276cf"
DefaultLimit = 20
MaxLimit = 100
MaxLimit = 500
)

0 comments on commit c3747c9

Please sign in to comment.