diff --git a/kernel/av/filter.go b/kernel/av/filter.go index 3700da5a7..3519cec3e 100644 --- a/kernel/av/filter.go +++ b/kernel/av/filter.go @@ -182,8 +182,7 @@ func (value *Value) Filter(filter *ViewFilter, attrView *AttributeView, rowID st return false } - value.Rollup.Contents = GetRollupContents(destAv, destKey, relVal.Relation.BlockIDs, nil) - value.Rollup.RenderContents(key.Rollup.Calc, destKey) + value.Rollup.BuildContents(destAv, destKey, relVal, key.Rollup.Calc, nil) for _, content := range value.Rollup.Contents { switch filter.Operator { case FilterOperatorContains: diff --git a/kernel/av/value.go b/kernel/av/value.go index e4af8bd20..e3873556f 100644 --- a/kernel/av/value.go +++ b/kernel/av/value.go @@ -796,9 +796,9 @@ type ValueRollup struct { Contents []*Value `json:"contents"` } -func GetRollupContents(destAv *AttributeView, destKey *Key, relationBlockIDs []string, furtherCollection Collection) (ret []*Value) { - ret = []*Value{} - for _, blockID := range relationBlockIDs { +func (r *ValueRollup) BuildContents(destAv *AttributeView, destKey *Key, relationVal *Value, calc *RollupCalc, furtherCollection Collection) { + r.Contents = nil + for _, blockID := range relationVal.Relation.BlockIDs { destVal := destAv.GetValue(destKey.ID, blockID) if nil != furtherCollection && KeyTypeTemplate == destKey.Type { destVal = furtherCollection.GetValue(blockID, destKey.ID) @@ -817,12 +817,13 @@ func GetRollupContents(destAv *AttributeView, destKey *Key, relationBlockIDs []s destVal.Number.FormatNumber() } - ret = append(ret, destVal.Clone()) + r.Contents = append(r.Contents, destVal.Clone()) } - return + + r.calcContents(calc, destKey) } -func (r *ValueRollup) RenderContents(calc *RollupCalc, destKey *Key) { +func (r *ValueRollup) calcContents(calc *RollupCalc, destKey *Key) { if nil == calc { return } diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go index b3d71a819..b4c582a4b 100644 --- a/kernel/model/attribute_view.go +++ b/kernel/model/attribute_view.go @@ -1534,8 +1534,7 @@ func GetBlockAttributeViewKeys(nodeID string) (ret []*BlockAttributeViewKeys) { } } - kv.Values[0].Rollup.Contents = av.GetRollupContents(destAv, destKey, relVal.Relation.BlockIDs, furtherCollection) - kv.Values[0].Rollup.RenderContents(kv.Key.Rollup.Calc, destKey) + kv.Values[0].Rollup.BuildContents(destAv, destKey, relVal, kv.Key.Rollup.Calc, furtherCollection) } } case av.KeyTypeRelation: diff --git a/kernel/sql/av.go b/kernel/sql/av.go index 9f3d7c0ec..fa8265da7 100644 --- a/kernel/sql/av.go +++ b/kernel/sql/av.go @@ -394,8 +394,7 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection } } - value.Rollup.Contents = av.GetRollupContents(destAv, destKey, relVal.Relation.BlockIDs, furtherCollection) - value.Rollup.RenderContents(rollupKey.Rollup.Calc, destKey) + value.Rollup.BuildContents(destAv, destKey, relVal, rollupKey.Rollup.Calc, furtherCollection) case av.KeyTypeRelation: // 渲染关联 value.Relation.Contents = nil relKey, _ := attrView.GetKey(value.KeyID)