Skip to content

Commit

Permalink
Merge pull request #255 from Tobeyw/dev-mindy
Browse files Browse the repository at this point in the history
fiix linit
  • Loading branch information
Tobeyw committed Jun 13, 2024
2 parents 5a12a45 + 5e7a138 commit 1e1ccca
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 26 deletions.
19 changes: 10 additions & 9 deletions neo3fura_http/biz/api/src.GetInfoByNFT.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ package api

import (
"encoding/json"
"fmt"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"io/ioutil"
"math/big"
"neo3fura_http/lib/type/Contract"
"neo3fura_http/lib/type/h160"
"neo3fura_http/lib/type/strval"
"neo3fura_http/var/stderr"
"net/http"
"os"
"strconv"
"time"

"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"

"neo3fura_http/lib/type/Contract"
"neo3fura_http/lib/type/h160"
"neo3fura_http/lib/type/strval"
"neo3fura_http/var/stderr"
)

func (me *T) GetInfoByNFT(args struct {
Expand Down Expand Up @@ -246,15 +247,15 @@ func GetNNSByAddress(address string) (string, string, error) {
} else if rt == "test" {
url = "https://megaoasis.ngd.network:8889/profile/get?address=" //test
}
fmt.Println(url + address)
//fmt.Println(url + address)
resp, err := http.Get(url + address)
if err != nil {
return "", "", err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
var nns, userName string
fmt.Println("body:", string(body))
//fmt.Println("body:", string(body))
if string(body) != "" && string(body) != "null" {
var data map[string]interface{}
err = json.Unmarshal(body, &data)
Expand Down
17 changes: 11 additions & 6 deletions neo3fura_http/biz/job/job.GetDailyTransactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,30 @@ func (me T) GetDailyTransactions() error {
if err != nil {
return err
}
r1, _, err := me.Client.QueryAll(struct {
r1, err := me.Client.QueryAggregate(struct {
Collection string
Index string
Sort bson.M
Filter bson.M
Pipeline []bson.M
Query []string
Limit int64
Skip int64
}{
Collection: "Transaction",
Index: "GetDailyTransactions",
Sort: bson.M{},
Filter: bson.M{"blocktime": bson.M{"$gt": r0["blocktime"].(int64) - 3600*24*1000}},
Query: []string{},
Filter: bson.M{},
Pipeline: []bson.M{
bson.M{"$match": bson.M{"blocktime": bson.M{"$gt": r0["blocktime"].(int64) - 3600*24*1000}}},
bson.M{"$group": bson.M{"_id": "$_id"}},
bson.M{"$count": "count"},
},
Query: []string{},
}, ret)

if err != nil {
return err
}
data := bson.M{"DailyTransactions": len(r1), "insertTime": r0["blocktime"]}
data := bson.M{"DailyTransactions": r1[0]["count"], "insertTime": r0["blocktime"]}
_, err = me.Client.SaveJob(struct {
Collection string
Data bson.M
Expand Down
19 changes: 13 additions & 6 deletions neo3fura_http/biz/job/job.GetHourlyTransactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package job

import (
"encoding/json"

"go.mongodb.org/mongo-driver/bson"
)

Expand All @@ -20,25 +21,31 @@ func (me T) GetHourlyTransactions() error {
if err != nil {
return err
}
r1, _, err := me.Client.QueryAll(struct {

r1, err := me.Client.QueryAggregate(struct {
Collection string
Index string
Sort bson.M
Filter bson.M
Pipeline []bson.M
Query []string
Limit int64
Skip int64
}{
Collection: "Transaction",
Index: "GetHourlyTransactions",
Sort: bson.M{},
Filter: bson.M{"blocktime": bson.M{"$gt": r0["blocktime"].(int64) - 3600*1000}},
Query: []string{},
Filter: bson.M{},
Pipeline: []bson.M{
bson.M{"$match": bson.M{"blocktime": bson.M{"$gt": r0["blocktime"].(int64) - 3600*1000}}},
bson.M{"$group": bson.M{"_id": "$_id"}},
bson.M{"$count": "count"},
},
Query: []string{},
}, ret)

if err != nil {
return err
}
data := bson.M{"HourlyTransactions": len(r1)}
data := bson.M{"HourlyTransactions": r1[0]["count"], "insertTime": r0["blocktime"].(int64) - 3600*1000}
_, err = me.Client.SaveJob(struct {
Collection string
Data bson.M
Expand Down
21 changes: 16 additions & 5 deletions neo3fura_http/biz/job/job.GetNewAddresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,31 @@ func (me T) GetNewAddresses() error {
return err
}

_, count, err := me.Client.QueryAll(struct {
r1, err := me.Client.QueryAggregate(struct {
Collection string
Index string
Sort bson.M
Filter bson.M
Pipeline []bson.M
Query []string
Limit int64
Skip int64
}{Collection: "Address", Index: "GetNewAddresses", Filter: bson.M{"firstusetime": bson.M{"$gt": r0["blocktime"].(int64) - 3600*24*1000}}}, ret)
}{
Collection: "Address",
Index: "GetNewAddresses",
Sort: bson.M{},
Filter: bson.M{},
Pipeline: []bson.M{
bson.M{"$match": bson.M{"firstusetime": bson.M{"$gt": r0["blocktime"].(int64) - 3600*24*1000}}},
bson.M{"$group": bson.M{"_id": "$_id"}},
bson.M{"$count": "count"},
},
Query: []string{},
}, ret)

if err != nil {
return err
}

data := bson.M{"NewAddresses": count, "insertTime": r0["blocktime"]}
data := bson.M{"NewAddresses": r1[0]["count"], "insertTime": r0["blocktime"]}
_, err = me.Client.SaveJob(struct {
Collection string
Data bson.M
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package watch
import (
"context"
"encoding/json"
"fmt"

"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
Expand Down Expand Up @@ -61,6 +62,7 @@ func (me *T) GetFirstEventByTransactionHash() error {
log2.Fatalf("Query Execution error:%v", err)
}
if len(r1) > 0 && r1["vmstate"] != nil && r1["vmstate"] != "" {
fmt.Println("TEST", r1["vmstate"], r2["vmstate"])
r2["vmstate"] = r1["vmstate"]
_, err = me.Client.SaveJob(struct {
Collection string
Expand Down

0 comments on commit 1e1ccca

Please sign in to comment.