mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 16:34:30 +01:00
rcd: Adding group parameter to stats
This commit is contained in:
parent
191cfb79d1
commit
e0356f5aae
@ -378,6 +378,7 @@ func (acc *Account) RemoteStats() (out rc.Params) {
|
||||
percentageDone = int(100 * float64(a) / float64(b))
|
||||
}
|
||||
out["percentage"] = percentageDone
|
||||
out["group"] = acc.stats.group
|
||||
|
||||
return out
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ type StatsInfo struct {
|
||||
startedTransfers []*Transfer // currently active transfers
|
||||
oldTimeRanges timeRanges // a merged list of time ranges for the transfers
|
||||
oldDuration time.Duration // duration of transfers we have culled
|
||||
group string
|
||||
}
|
||||
|
||||
// NewStats creates an initialised StatsInfo
|
||||
|
@ -245,6 +245,7 @@ func GlobalStats() *StatsInfo {
|
||||
// NewStatsGroup creates new stats under named group.
|
||||
func NewStatsGroup(group string) *StatsInfo {
|
||||
stats := NewStats()
|
||||
stats.group = group
|
||||
groups.set(group, stats)
|
||||
return stats
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ type TransferSnapshot struct {
|
||||
StartedAt time.Time `json:"started_at"`
|
||||
CompletedAt time.Time `json:"completed_at,omitempty"`
|
||||
Error error `json:"-"`
|
||||
Group string `json:"group"`
|
||||
}
|
||||
|
||||
// MarshalJSON implements json.Marshaler interface.
|
||||
@ -26,6 +27,7 @@ func (as TransferSnapshot) MarshalJSON() ([]byte, error) {
|
||||
if as.Error != nil {
|
||||
err = as.Error.Error()
|
||||
}
|
||||
|
||||
type Alias TransferSnapshot
|
||||
return json.Marshal(&struct {
|
||||
Error string `json:"error"`
|
||||
@ -176,5 +178,6 @@ func (tr *Transfer) Snapshot() TransferSnapshot {
|
||||
StartedAt: tr.startedAt,
|
||||
CompletedAt: tr.completedAt,
|
||||
Error: tr.err,
|
||||
Group: tr.stats.group,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user