Skip to content

Commit

Permalink
Show pipehealth when feeding
Browse files Browse the repository at this point in the history
  • Loading branch information
rcy committed Oct 7, 2023
1 parent 35b0ccd commit 1de7345
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions handlers/feed_me.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,40 @@ func FeedMe(params bot.HandlerParams) error {
return err
}

params.Privmsgf(params.Target, "%s (from ??? %s ago)", note.Text, util.Since(note.CreatedAt))
ready, fermenting, err := health()
if err != nil {
return err
}

params.Privmsgf(params.Target, "%s (%s ago) [pipe=%d+%d]", note.Text, util.Since(note.CreatedAt), ready, fermenting)

return nil
}

func PipeHealth(params bot.HandlerParams) error {
readyNotes, err := candidateLinks(MINAGE)
ready, fermenting, err := health()
if err != nil {
return err
}

params.Privmsgf(params.Target, "%d links ready to serve (%d fermenting)", ready, fermenting)

return nil
}

// Return ready, fermenting, error
func health() (int, int, error) {
readyNotes, err := candidateLinks(MINAGE)
if err != nil {
return 0, 0, err
}
totalNotes, err := candidateLinks(0)
if err != nil {
return err
return 0, 0, err
}

ready := len(readyNotes)
fermenting := len(totalNotes) - ready

params.Privmsgf(params.Target, "%d links ready to serve (%d fermenting)", ready, fermenting)

return nil
return ready, fermenting, nil
}

0 comments on commit 1de7345

Please sign in to comment.