🎨 Add Rollup column to database table view https://github.com/siyuan-note/siyuan/issues/9958

This commit is contained in:
Daniel 2024-01-01 00:46:00 +08:00
parent 3d3b2df07a
commit 333cba07f4
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -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)) + "%"}
}
}