mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-10 09:14:20 +01:00
🎨 Add "Show unique values" to the calculation of the database rollup field https://github.com/siyuan-note/siyuan/issues/15852
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
66125f4b1d
commit
812dadb452
16 changed files with 54 additions and 13 deletions
|
|
@ -834,6 +834,17 @@ func (r *ValueRollup) calcContents(calc *RollupCalc, destKey *Key) {
|
|||
|
||||
switch calc.Operator {
|
||||
case CalcOperatorNone:
|
||||
case CalcOperatorUniqueValues:
|
||||
var newContents []*Value
|
||||
uniqueValues := map[string]bool{}
|
||||
for _, v := range r.Contents {
|
||||
key := v.String(true)
|
||||
if !uniqueValues[key] {
|
||||
uniqueValues[key] = true
|
||||
newContents = append(newContents, v)
|
||||
}
|
||||
}
|
||||
r.Contents = newContents
|
||||
case CalcOperatorCountAll:
|
||||
r.Contents = []*Value{{Type: KeyTypeNumber, Number: NewFormattedValueNumber(float64(len(r.Contents)), NumberFormatNone)}}
|
||||
case CalcOperatorCountValues:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue