grid2: add slack attachment footer

This commit is contained in:
c9s 2022-12-15 17:47:34 +08:00
parent 19478b1fbc
commit c0598a05f6
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -51,6 +51,11 @@ func (s *GridProfitStats) AddTrade(trade types.Trade) {
} else { } else {
s.TotalFee[trade.FeeCurrency] = trade.Fee s.TotalFee[trade.FeeCurrency] = trade.Fee
} }
if s.Since == nil {
t := trade.Time.Time()
s.Since = &t
}
} }
func (s *GridProfitStats) AddProfit(profit *GridProfit) { func (s *GridProfitStats) AddProfit(profit *GridProfit) {
@ -115,13 +120,18 @@ func (s *GridProfitStats) SlackAttachment() slack.Attachment {
Value: fee.String() + " " + feeCurrency, Value: fee.String() + " " + feeCurrency,
Short: true, Short: true,
}) })
} }
} }
footer := "Total grid profit stats"
if s.Since != nil {
footer += fmt.Sprintf(" since %s", s.Since.String())
}
return slack.Attachment{ return slack.Attachment{
Title: "Grid Profit Stats", Title: "Grid Profit Stats",
Color: "warning", Color: "warning",
Fields: fields, Fields: fields,
Footer: footer,
} }
} }