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: Database grouping by field https://github.com/siyuan-note/siyuan/issues/10964
Danielf859b5933754
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex 9ed567f735..88dae2279f 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -160,6 +160,14 @@ func SetAttributeViewGroup(avID, blockID string, group *av.ViewGroup) (err errorvar rangeStart, rangeEnd float64switch group.Method {case av.GroupMethodValue:+ if av.GroupOrderMan != group.Order {+ sort.SliceStable(items, func(i, j int) bool {+ if av.GroupOrderAsc == group.Order {+ return items[i].GetValue(group.Field).String(false) < items[j].GetValue(group.Field).String(false)+ }+ return items[i].GetValue(group.Field).String(false) > items[j].GetValue(group.Field).String(false)+ })+ }case av.GroupMethodRangeNum:if nil == group.Range {logging.LogWarnf("range is nil in av [%s]", avID)@@ -173,7 +181,13 @@ func SetAttributeViewGroup(avID, blockID string, group *av.ViewGroup) (err error}return items[i].GetValue(group.Field).Number.Content > items[j].GetValue(group.Field).Number.Content})- // TODO Database grouping by field https://github.com/siyuan-note/siyuan/issues/10964+ case av.GroupMethodDateDay, av.GroupMethodDateWeek, av.GroupMethodDateMonth, av.GroupMethodDateYear, av.GroupMethodDateRelative:+ sort.SliceStable(items, func(i, j int) bool {+ if av.GroupOrderAsc == group.Order {+ return items[i].GetValue(group.Field).Date.Content < items[j].GetValue(group.Field).Date.Content+ }+ return items[i].GetValue(group.Field).Date.Content > items[j].GetValue(group.Field).Date.Content+ })}groupItemsMap := map[string][]av.Item{}@@ -186,15 +200,6 @@ func SetAttributeViewGroup(avID, blockID string, group *av.ViewGroup) (err errorcase av.GroupMethodValue:groupName = value.String(false)case av.GroupMethodRangeNum:- if value.Type != av.KeyTypeNumber {- logging.LogWarnf("item [%s] value [%s] type is not number in av [%s]", item.GetID(), value.String(false), avID)- return- }- if nil == value.Number {- logging.LogWarnf("item [%s] value [%s] number is nil in av [%s]", item.GetID(), value.String(false), avID)- return- }-if group.Range.NumStart > value.Number.Content || group.Range.NumEnd < value.Number.Content {groupName = notInRangebreak@@ -208,6 +213,29 @@ func SetAttributeViewGroup(avID, blockID string, group *av.ViewGroup) (err errorif rangeStart <= value.Number.Content && rangeEnd >= value.Number.Content {groupName = fmt.Sprintf("%s - %s", strconv.FormatFloat(rangeStart, 'f', -1, 64), strconv.FormatFloat(rangeEnd, 'f', -1, 64))}+ case av.GroupMethodDateDay, av.GroupMethodDateWeek, av.GroupMethodDateMonth, av.GroupMethodDateYear, av.GroupMethodDateRelative:+ var contentTime time.Time+ switch value.Type {+ case av.KeyTypeDate:+ contentTime = time.UnixMilli(value.Date.Content)+ case av.KeyTypeCreated:+ contentTime = time.UnixMilli(value.Created.Content)+ case av.KeyTypeUpdated:+ contentTime = time.UnixMilli(value.Updated.Content)+ }+ switch group.Method {+ case av.GroupMethodDateDay:+ groupName = contentTime.Format("2006-01-02")+ case av.GroupMethodDateWeek:+ year, week := contentTime.ISOWeek()+ groupName = fmt.Sprintf("%d-W%02d", year, week)+ case av.GroupMethodDateMonth:+ groupName = contentTime.Format("2006-01")+ case av.GroupMethodDateYear:+ groupName = contentTime.Format("2006")+ case av.GroupMethodDateRelative:++ }}}groupItemsMap[groupName] = append(groupItemsMap[groupName], item)