🎨 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-16 00:39:38 +08:00
parent a8b5c513ae
commit 1344859c1e
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 59 additions and 10 deletions

View file

@ -1710,9 +1710,35 @@ func calcFieldRollup(collection Collection, field Field, fieldIndex int) {
values := item.GetValues()
if nil != values[fieldIndex] && nil != values[fieldIndex].Rollup {
for _, content := range values[fieldIndex].Rollup.Contents {
if !uniqueValues[content.String(true)] {
uniqueValues[content.String(true)] = true
countUniqueValues++
switch content.Type {
case KeyTypeRelation:
for _, relationVal := range content.Relation.Contents {
key := relationVal.String(true)
if !uniqueValues[key] {
uniqueValues[key] = true
countUniqueValues++
}
}
case KeyTypeMSelect:
for _, mSelectVal := range content.MSelect {
if !uniqueValues[mSelectVal.Content] {
uniqueValues[mSelectVal.Content] = true
countUniqueValues++
}
}
case KeyTypeMAsset:
for _, mAssetVal := range content.MAsset {
if !uniqueValues[mAssetVal.Content] {
uniqueValues[mAssetVal.Content] = true
countUniqueValues++
}
}
default:
key := content.String(true)
if !uniqueValues[key] {
uniqueValues[key] = true
countUniqueValues++
}
}
}
}