Skip to content

Commit

Permalink
Merge 4cdd126 into 12ae8e7
Browse files Browse the repository at this point in the history
  • Loading branch information
brotherlogic committed Jan 2, 2019
2 parents 12ae8e7 + 4cdd126 commit 3757b99
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 25 deletions.
85 changes: 61 additions & 24 deletions proto/wantslist.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion proto/wantslist.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ message Config {

message WantListEntry {
int32 want = 1;
int32 index = 2;
int32 index = 2;

enum Status {
UNPROCESSED = 0;
WANTED = 1;
IN_COLLECTION = 2;
}

Status status = 3;
}

message WantList {
Expand Down
18 changes: 18 additions & 0 deletions wantslist.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,26 @@ func (s *Server) Mote(ctx context.Context, master bool) error {

// GetState gets the state of the server
func (s *Server) GetState() []*pbg.State {
unprocCount := int64(0)
wantedCount := int64(0)
unknownCount := int64(0)
for _, list := range s.config.Lists {
for _, entry := range list.Wants {
switch entry.Status {
case pb.WantListEntry_UNPROCESSED:
unprocCount++
case pb.WantListEntry_WANTED:
wantedCount++
default:
unknownCount++
}
}
}
return []*pbg.State{
&pbg.State{Key: "lists", Value: int64(len(s.config.Lists))},
&pbg.State{Key: "unproc", Value: unprocCount},
&pbg.State{Key: "wanted", Value: wantedCount},
&pbg.State{Key: "unknown", Value: unknownCount},
}
}

Expand Down

0 comments on commit 3757b99

Please sign in to comment.