🎨 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:
Daniel 2025-09-15 23:07:09 +08:00
parent 66125f4b1d
commit 812dadb452
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
16 changed files with 54 additions and 13 deletions

View file

@ -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: