Refactored total change counts

Design is more uniformed and standardized, patterns are bubbling up. I think we're ready to tackle the schema soon.

Signed-off-by: Dave Shanley <dave@quobix.com>
This commit is contained in:
Dave Shanley
2022-10-05 11:24:37 -04:00
parent 0b2c3c1201
commit 3649dc594f
11 changed files with 36 additions and 26 deletions

View File

@@ -16,9 +16,9 @@ type ExternalDocChanges struct {
// TotalChanges returns a count of everything that changed
func (e *ExternalDocChanges) TotalChanges() int {
c := len(e.Changes)
c := e.PropertyChanges.TotalChanges()
if e.ExtensionChanges != nil {
c += len(e.ExtensionChanges.Changes)
c += e.ExtensionChanges.TotalChanges()
}
return c
}
@@ -65,7 +65,7 @@ func CompareExternalDocs(l, r *base.ExternalDoc) *ExternalDocChanges {
// check extensions
dc.ExtensionChanges = CheckExtensions(l, r)
if len(dc.Changes) <= 0 && dc.ExtensionChanges == nil {
if dc.TotalChanges() <= 0 {
return nil
}
return dc