Skip to content

Commit

Permalink
add limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobeyw committed Jun 7, 2024
1 parent 0ab1cd2 commit 3567186
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
35 changes: 19 additions & 16 deletions neo3fura_http/lib/cli/src.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import (
"encoding/hex"
"encoding/json"
"fmt"

"github.com/go-redis/redis/v8"
"github.com/joeqian10/neo3-gogogo/rpc"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"

log2 "neo3fura_http/lib/log"
"neo3fura_http/lib/type/consts"
"neo3fura_http/lib/type/h160"
"neo3fura_http/var/stderr"
)
Expand Down Expand Up @@ -135,11 +138,11 @@ func (me *T) QueryAll(args struct {
Skip int64
}, ret *json.RawMessage) ([]map[string]interface{}, int64, error) {

//if args.Limit == 0 {
// args.Limit = limit2.DefaultLimit
//} else if args.Limit > limit2.MaxLimit {
// args.Limit = limit2.MaxLimit
//}
if args.Limit == 0 {
args.Limit = consts.DefaultLimit
} else if args.Limit > consts.MaxLimit {
args.Limit = consts.MaxLimit
}

var results []map[string]interface{}
convert := make([]map[string]interface{}, 0)
Expand Down Expand Up @@ -337,17 +340,17 @@ func (me *T) QueryAggregate(args struct {
Query []string
}, ret *json.RawMessage) ([]map[string]interface{}, error) {

//for _, v := range args.Pipeline {
// limit := v["$limit"]
// if limit != nil {
// if limit.(int64) == 0 {
// v["$limit"] = limit2.DefaultLimit
// }
// if limit.(int64) > limit2.MaxLimit {
// v["$limit"] = limit2.MaxLimit
// }
// }
//}
for _, v := range args.Pipeline {
limit := v["$limit"]
if limit != nil {
if limit.(int64) == 0 {
v["$limit"] = consts.DefaultLimit
}
if limit.(int64) > consts.MaxLimit {
v["$limit"] = consts.MaxLimit
}
}
}

var results []map[string]interface{}
convert := make([]map[string]interface{}, 0)
Expand Down
12 changes: 7 additions & 5 deletions neo3fura_http/lib/type/consts/src.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package consts

const (
ShortForm = "2006-01-02"
BNEO_Main = "0x48c40d4666f93408be1bef038b6722404d9a4c2a"
BNEO_Test = "0x85deac50febfd93988d3f391dea54e8289e43e9e"
NEO = "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5"
GAS = "0xd2a4cff31913016155e38e474a2c06d08be276cf"
ShortForm = "2006-01-02"
BNEO_Main = "0x48c40d4666f93408be1bef038b6722404d9a4c2a"
BNEO_Test = "0x85deac50febfd93988d3f391dea54e8289e43e9e"
NEO = "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5"
GAS = "0xd2a4cff31913016155e38e474a2c06d08be276cf"
DefaultLimit = 20
MaxLimit = 100
)

0 comments on commit 3567186

Please sign in to comment.