Skip to content
This repository was archived by the owner on Nov 14, 2023. It is now read-only.

Commit fa94978

Browse files
Merge pull request #1387 from irisnet/develop
R4R: add icon for goz test net explorer
2 parents 9f879e4 + 3ac4c26 commit fa94978

File tree

12 files changed

+119
-92
lines changed

12 files changed

+119
-92
lines changed

backend/orm/document/static_rewards.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"gopkg.in/mgo.v2/bson"
77
"gopkg.in/mgo.v2/txn"
88
"time"
9+
"github.com/irisnet/explorer/backend/utils"
910
)
1011

1112
const (
@@ -16,14 +17,14 @@ const (
1617
)
1718

1819
type ExStaticRewards struct {
19-
Id bson.ObjectId `bson:"_id"`
20-
Address string `bson:"address"`
21-
Date time.Time `bson:"date"`
22-
Total []Rewards `bson:"total"`
23-
//DelegationsDetail []DelegationsRewards `bson:"delegations_detail"`
24-
Delegations []Rewards `bson:"delegations"`
25-
Commission []Rewards `bson:"commission"`
26-
CreateAt int64 `bson:"create_at"`
20+
Id bson.ObjectId `bson:"_id"`
21+
Address string `bson:"address"`
22+
Date time.Time `bson:"date"`
23+
Total []Rewards `bson:"total"`
24+
Delegation utils.Coin `bson:"delegation"`
25+
DelegationsRewards []Rewards `bson:"delegations_rewards"`
26+
Commission []Rewards `bson:"commission"`
27+
CreateAt int64 `bson:"create_at"`
2728
}
2829

2930
type Rewards struct {

backend/task/static_rewards.go

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,19 @@ func (task StaticRewardsTask) getRewardsFromLcd(address string) (utils.CoinsAsSt
5050

5151
func (task StaticRewardsTask) getAllAccountRewards() ([]txn.Op, error) {
5252

53-
accAddrs, err := task.getAccountFromDb()
53+
accs, err := task.getAccountFromDb()
5454
if err != nil {
5555
return nil, err
5656
}
5757

58-
return task.saveExStaticRewardsOps(accAddrs)
58+
return task.saveExStaticRewardsOps(accs)
5959
}
6060

61-
func (task StaticRewardsTask) saveExStaticRewardsOps(accAddrs []string) ([]txn.Op, error) {
61+
func (task StaticRewardsTask) saveExStaticRewardsOps(accs []document.Account) ([]txn.Op, error) {
6262
today := utils.TruncateTime(time.Now().In(cstZone), utils.Day)
63-
ops := make([]txn.Op, 0, len(accAddrs))
63+
ops := make([]txn.Op, 0, len(accs))
6464
now := time.Now().Unix()
65-
for _, addr := range accAddrs {
65+
for _, addr := range accs {
6666
item, err := task.loadModelRewards(addr, today)
6767
item.CreateAt = now
6868
if err != nil {
@@ -78,26 +78,27 @@ func (task StaticRewardsTask) saveExStaticRewardsOps(accAddrs []string) ([]txn.O
7878
return ops, nil
7979
}
8080

81-
func (task StaticRewardsTask) loadModelRewards(addr string, today time.Time) (document.ExStaticRewards, error) {
82-
commisstionRds, _, totalRds, err := task.getRewardsFromLcd(addr)
81+
func (task StaticRewardsTask) loadModelRewards(account document.Account, today time.Time) (document.ExStaticRewards, error) {
82+
commisstionRds, _, totalRds, err := task.getRewardsFromLcd(account.Address)
8383
if err != nil {
8484
logger.Warn(err.Error())
8585
return document.ExStaticRewards{}, err
8686
}
8787

8888
item := document.ExStaticRewards{
8989
Id: bson.NewObjectId(),
90-
Address: addr,
90+
Address: account.Address,
9191
Date: today.In(cstZone),
9292
Total: task.loadRewards(totalRds),
9393
Commission: task.loadRewards(commisstionRds),
94+
Delegation: account.Delegation,
9495
//DelegationsDetail: task.loadDelegationsRewardsDetail(delegationsRds),
9596
}
9697
if len(item.Total) > 0 {
9798
if len(item.Commission) == 0 {
98-
item.Delegations = item.Total
99+
item.DelegationsRewards = item.Total
99100
} else {
100-
item.Delegations = task.loadDelegationsRewards(item.Total[0], item.Commission[0])
101+
item.DelegationsRewards = task.loadDelegationsRewards(item.Total[0], item.Commission[0])
101102
}
102103
}
103104
return item, nil
@@ -162,40 +163,34 @@ func (task StaticRewardsTask) loadDelegationsRewards(total, commission document.
162163
return nil
163164
}
164165

165-
var ret []document.Rewards
166-
subValueFloat64, ok := subValue.Float64()
167-
if ok {
168-
one := document.Rewards{
169-
Iris: subValueFloat64,
170-
IrisAtto: subValue.String(),
171-
}
172-
ret = []document.Rewards{one}
166+
167+
subValueFloat64, _ := subValue.Float64()
168+
one := document.Rewards{
169+
Iris: subValueFloat64 / math.Pow10(18),
170+
IrisAtto: subValue.FloatString(0),
173171
}
174172

175-
return ret
173+
return []document.Rewards{one}
176174
}
177175

178-
func (task StaticRewardsTask) getAccountFromDb() ([]string, error) {
176+
func (task StaticRewardsTask) getAccountFromDb() ([]document.Account, error) {
179177
size := 100
180178
offset := 0
181179
length := size
182-
var accAddress []string
180+
var ret []document.Account
183181
for {
184182
accounts, err := task.account.GetDelegatores(offset, size)
185183
if err != nil {
186184
logger.Error(err.Error())
187-
return accAddress, err
188-
}
189-
190-
for _, val := range accounts {
191-
accAddress = append(accAddress, val.Address)
185+
return accounts, err
192186
}
187+
ret = append(ret, accounts...)
193188
length = len(accounts)
194189
if length < size {
195190
break
196191
}
197192
offset += length
198193
}
199194

200-
return accAddress, nil
195+
return ret, nil
201196
}

frontend/icon/iconfont.css

Lines changed: 14 additions & 6 deletions
Large diffs are not rendered by default.

frontend/icon/iconfont.eot

760 Bytes
Binary file not shown.

frontend/icon/iconfont.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/icon/iconfont.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@
55
"css_prefix_text": "icon",
66
"description": "",
77
"glyphs": [
8+
{
9+
"icon_id": "14183675",
10+
"name": "GOZ",
11+
"font_class": "GOZ",
12+
"unicode": "e65b",
13+
"unicode_decimal": 58971
14+
},
15+
{
16+
"icon_id": "13982898",
17+
"name": "缺省默认头像",
18+
"font_class": "queshengmorentouxiang",
19+
"unicode": "e659",
20+
"unicode_decimal": 58969
21+
},
822
{
923
"icon_id": "13851059",
1024
"name": "展开",

0 commit comments

Comments
 (0)