mirror of
https://github.com/niusmallnan/steve.git
synced 2025-07-31 05:50:08 +00:00
Merge pull request #8 from ibuildthecloud/master
Don't return revision in counts and only return error/transitions states
This commit is contained in:
commit
f0b94379d1
@ -68,7 +68,7 @@ func (s *Summary) DeepCopy() *Summary {
|
||||
type ItemCount struct {
|
||||
Summary Summary `json:"summary,omitempty"`
|
||||
Namespaces map[string]Summary `json:"namespaces,omitempty"`
|
||||
Revision int `json:"revision,omitempty"`
|
||||
Revision int `json:"-"`
|
||||
}
|
||||
|
||||
func (i *ItemCount) DeepCopy() *ItemCount {
|
||||
@ -163,7 +163,7 @@ func (s *Store) Watch(apiOp *types.APIRequest, schema *types.APISchema, w types.
|
||||
if _, _, _, oldSummary, ok := getInfo(oldObj); ok {
|
||||
if oldSummary.Transitioning == summary.Transitioning &&
|
||||
oldSummary.Error == summary.Error &&
|
||||
oldSummary.State == summary.State {
|
||||
simpleState(oldSummary) == simpleState(summary) {
|
||||
return nil
|
||||
}
|
||||
itemCount = removeCounts(itemCount, namespace, oldSummary)
|
||||
@ -276,11 +276,11 @@ func removeSummary(counts Summary, summary summary.Summary) Summary {
|
||||
if summary.Error {
|
||||
counts.Error--
|
||||
}
|
||||
if summary.State != "" {
|
||||
if simpleState(summary) != "" {
|
||||
if counts.States == nil {
|
||||
counts.States = map[string]int{}
|
||||
}
|
||||
counts.States[summary.State] -= 1
|
||||
counts.States[simpleState(summary)] -= 1
|
||||
}
|
||||
return counts
|
||||
}
|
||||
@ -293,15 +293,24 @@ func addSummary(counts Summary, summary summary.Summary) Summary {
|
||||
if summary.Error {
|
||||
counts.Error++
|
||||
}
|
||||
if summary.State != "" {
|
||||
if simpleState(summary) != "" {
|
||||
if counts.States == nil {
|
||||
counts.States = map[string]int{}
|
||||
}
|
||||
counts.States[summary.State] += 1
|
||||
counts.States[simpleState(summary)] += 1
|
||||
}
|
||||
return counts
|
||||
}
|
||||
|
||||
func simpleState(summary summary.Summary) string {
|
||||
if summary.Error {
|
||||
return "error"
|
||||
} else if summary.Transitioning {
|
||||
return "in-progress"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (s *Store) getCount(apiOp *types.APIRequest) Count {
|
||||
counts := map[string]ItemCount{}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user