mirror of
https://github.com/hibiken/asynq.git
synced 2024-11-10 11:31:58 +08:00
(cli): Update stats command to print the number of aggregating tasks
This commit is contained in:
parent
578321f226
commit
451be7e50f
@ -61,6 +61,7 @@ func init() {
|
|||||||
type AggregateStats struct {
|
type AggregateStats struct {
|
||||||
Active int `json:"active"`
|
Active int `json:"active"`
|
||||||
Pending int `json:"pending"`
|
Pending int `json:"pending"`
|
||||||
|
Aggregating int `json:"aggregating"`
|
||||||
Scheduled int `json:"scheduled"`
|
Scheduled int `json:"scheduled"`
|
||||||
Retry int `json:"retry"`
|
Retry int `json:"retry"`
|
||||||
Archived int `json:"archived"`
|
Archived int `json:"archived"`
|
||||||
@ -95,6 +96,7 @@ func stats(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
aggStats.Active += s.Active
|
aggStats.Active += s.Active
|
||||||
aggStats.Pending += s.Pending
|
aggStats.Pending += s.Pending
|
||||||
|
aggStats.Aggregating += s.Aggregating
|
||||||
aggStats.Scheduled += s.Scheduled
|
aggStats.Scheduled += s.Scheduled
|
||||||
aggStats.Retry += s.Retry
|
aggStats.Retry += s.Retry
|
||||||
aggStats.Archived += s.Archived
|
aggStats.Archived += s.Archived
|
||||||
@ -155,13 +157,13 @@ func stats(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func printStatsByState(s *AggregateStats) {
|
func printStatsByState(s *AggregateStats) {
|
||||||
format := strings.Repeat("%v\t", 6) + "\n"
|
format := strings.Repeat("%v\t", 7) + "\n"
|
||||||
tw := new(tabwriter.Writer).Init(os.Stdout, 0, 8, 2, ' ', 0)
|
tw := new(tabwriter.Writer).Init(os.Stdout, 0, 8, 2, ' ', 0)
|
||||||
fmt.Fprintf(tw, format, "active", "pending", "scheduled", "retry", "archived", "completed")
|
fmt.Fprintf(tw, format, "active", "pending", "aggregating", "scheduled", "retry", "archived", "completed")
|
||||||
width := maxInt(9 /* defaultWidth */, maxWidthOf(s.Active, s.Pending, s.Scheduled, s.Retry, s.Archived, s.Completed)) // length of widest column
|
width := maxInt(9 /* defaultWidth */, maxWidthOf(s.Active, s.Pending, s.Aggregating, s.Scheduled, s.Retry, s.Archived, s.Completed)) // length of widest column
|
||||||
sep := strings.Repeat("-", width)
|
sep := strings.Repeat("-", width)
|
||||||
fmt.Fprintf(tw, format, sep, sep, sep, sep, sep, sep)
|
fmt.Fprintf(tw, format, sep, sep, sep, sep, sep, sep, sep)
|
||||||
fmt.Fprintf(tw, format, s.Active, s.Pending, s.Scheduled, s.Retry, s.Archived, s.Completed)
|
fmt.Fprintf(tw, format, s.Active, s.Pending, s.Aggregating, s.Scheduled, s.Retry, s.Archived, s.Completed)
|
||||||
tw.Flush()
|
tw.Flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user