An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Attribute View columns calculate https://github.com/siyuan-note/siyuan/issues/8699
Danieleafdf0ab7ed0
diff --git a/kernel/av/table.go b/kernel/av/table.goindex ca49b8fee2..78d1fea579 100644--- a/kernel/av/table.go+++ b/kernel/av/table.go@@ -609,7 +609,7 @@ func (table *Table) calcColNumber(col *TableColumn, colIndex int) {countUniqueValues := 0uniqueValues := map[float64]bool{}for _, row := range table.Rows {- if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Number && row.Cells[colIndex].Value.Number.IsNotEmpty {+ if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Number && (row.Cells[colIndex].Value.Number.IsNotEmpty || 0 != row.Cells[colIndex].Value.Number.Content) {if !uniqueValues[row.Cells[colIndex].Value.Number.Content] {uniqueValues[row.Cells[colIndex].Value.Number.Content] = truecountUniqueValues++@@ -628,7 +628,7 @@ func (table *Table) calcColNumber(col *TableColumn, colIndex int) {case CalcOperatorCountNotEmpty:countNotEmpty := 0for _, row := range table.Rows {- if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Number && row.Cells[colIndex].Value.Number.IsNotEmpty {+ if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Number && (row.Cells[colIndex].Value.Number.IsNotEmpty || 0 != row.Cells[colIndex].Value.Number.Content) {countNotEmpty++}}@@ -644,7 +644,7 @@ func (table *Table) calcColNumber(col *TableColumn, colIndex int) {case CalcOperatorPercentNotEmpty:countNotEmpty := 0for _, row := range table.Rows {- if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Number && row.Cells[colIndex].Value.Number.IsNotEmpty {+ if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Number && (row.Cells[colIndex].Value.Number.IsNotEmpty || 0 != row.Cells[colIndex].Value.Number.Content) {countNotEmpty++}}@@ -652,7 +652,7 @@ func (table *Table) calcColNumber(col *TableColumn, colIndex int) {case CalcOperatorSum:sum := 0.0for _, row := range table.Rows {- if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Number && row.Cells[colIndex].Value.Number.IsNotEmpty {+ if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Number && (row.Cells[colIndex].Value.Number.IsNotEmpty || 0 != row.Cells[colIndex].Value.Number.Content) {sum += row.Cells[colIndex].Value.Number.Content}}@@ -661,7 +661,7 @@ func (table *Table) calcColNumber(col *TableColumn, colIndex int) {sum := 0.0count := 0for _, row := range table.Rows {- if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Number && row.Cells[colIndex].Value.Number.IsNotEmpty {+ if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Number && (row.Cells[colIndex].Value.Number.IsNotEmpty || 0 != row.Cells[colIndex].Value.Number.Content) {sum += row.Cells[colIndex].Value.Number.Contentcount++}@@ -670,7 +670,7 @@ func (table *Table) calcColNumber(col *TableColumn, colIndex int) {case CalcOperatorMedian:values := []float64{}for _, row := range table.Rows {- if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Number && row.Cells[colIndex].Value.Number.IsNotEmpty {+ if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Number && (row.Cells[colIndex].Value.Number.IsNotEmpty || 0 != row.Cells[colIndex].Value.Number.Content) {values = append(values, row.Cells[colIndex].Value.Number.Content)}}@@ -687,7 +687,7 @@ func (table *Table) calcColNumber(col *TableColumn, colIndex int) {case CalcOperatorMin:min := math.MaxFloat64for _, row := range table.Rows {- if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Number && row.Cells[colIndex].Value.Number.IsNotEmpty {+ if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Number && (row.Cells[colIndex].Value.Number.IsNotEmpty || 0 != row.Cells[colIndex].Value.Number.Content) {if row.Cells[colIndex].Value.Number.Content < min {min = row.Cells[colIndex].Value.Number.Content}@@ -701,7 +701,7 @@ func (table *Table) calcColNumber(col *TableColumn, colIndex int) {case CalcOperatorMax:max := -math.MaxFloat64for _, row := range table.Rows {- if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Number && row.Cells[colIndex].Value.Number.IsNotEmpty {+ if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Number && (row.Cells[colIndex].Value.Number.IsNotEmpty || 0 != row.Cells[colIndex].Value.Number.Content) {if row.Cells[colIndex].Value.Number.Content > max {max = row.Cells[colIndex].Value.Number.Content}@@ -716,7 +716,7 @@ func (table *Table) calcColNumber(col *TableColumn, colIndex int) {min := math.MaxFloat64max := -math.MaxFloat64for _, row := range table.Rows {- if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Number && row.Cells[colIndex].Value.Number.IsNotEmpty {+ if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Number && (row.Cells[colIndex].Value.Number.IsNotEmpty || 0 != row.Cells[colIndex].Value.Number.Content) {if row.Cells[colIndex].Value.Number.Content < min {min = row.Cells[colIndex].Value.Number.Content}