mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 00:38:49 +01:00
🎨 The database supports calculating the "Percent unique values" of the field https://github.com/siyuan-note/siyuan/issues/13192
This commit is contained in:
parent
36df3d5ea1
commit
1e28680a58
15 changed files with 289 additions and 20 deletions
|
|
@ -730,6 +730,18 @@ func (r *ValueRollup) RenderContents(calc *RollupCalc, destKey *Key) {
|
|||
if 0 < len(r.Contents) {
|
||||
r.Contents = []*Value{{Type: KeyTypeNumber, Number: NewFormattedValueNumber(float64(countNonEmpty)/float64(len(r.Contents)), NumberFormatPercent)}}
|
||||
}
|
||||
case CalcOperatorPercentUniqueValues:
|
||||
countUniqueValues := 0
|
||||
uniqueValues := map[string]bool{}
|
||||
for _, v := range r.Contents {
|
||||
if _, ok := uniqueValues[v.String(true)]; !ok {
|
||||
uniqueValues[v.String(true)] = true
|
||||
countUniqueValues++
|
||||
}
|
||||
}
|
||||
if 0 < len(r.Contents) {
|
||||
r.Contents = []*Value{{Type: KeyTypeNumber, Number: NewFormattedValueNumber(float64(countUniqueValues)/float64(len(r.Contents)), NumberFormatPercent)}}
|
||||
}
|
||||
case CalcOperatorSum:
|
||||
sum := 0.0
|
||||
for _, v := range r.Contents {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue