mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +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
a8b5c513ae
commit
1344859c1e
2 changed files with 59 additions and 10 deletions
|
|
@ -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++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue