From 333cba07f4c214395cf8fcdf7131eeefcaf22537 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Mon, 1 Jan 2024 00:46:00 +0800 Subject: [PATCH] :art: Add Rollup column to database table view https://github.com/siyuan-note/siyuan/issues/9958 --- kernel/av/value.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/kernel/av/value.go b/kernel/av/value.go index 46ab870f9..64b724dff 100644 --- a/kernel/av/value.go +++ b/kernel/av/value.go @@ -597,5 +597,37 @@ func (r *ValueRollup) RenderContents(calc *RollupCalc) { } } r.Contents = []string{strconv.FormatFloat(max-min, 'f', -1, 64)} + case CalcOperatorChecked: + countChecked := 0 + for _, v := range r.Contents { + if "√" == v { + countChecked++ + } + } + r.Contents = []string{strconv.Itoa(countChecked)} + case CalcOperatorUnchecked: + countUnchecked := 0 + for _, v := range r.Contents { + if "√" != v { + countUnchecked++ + } + } + r.Contents = []string{strconv.Itoa(countUnchecked)} + case CalcOperatorPercentChecked: + countChecked := 0 + for _, v := range r.Contents { + if "√" == v { + countChecked++ + } + } + r.Contents = []string{strconv.Itoa(countChecked*100/len(r.Contents)) + "%"} + case CalcOperatorPercentUnchecked: + countUnchecked := 0 + for _, v := range r.Contents { + if "√" != v { + countUnchecked++ + } + } + r.Contents = []string{strconv.Itoa(countUnchecked*100/len(r.Contents)) + "%"} } }