Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve database template field grouping https://github.com/siyuan-note/siyuan/issues/15687

Daniel2de55d2e635a
diff --git a/kernel/model/attribute_view_render.go b/kernel/model/attribute_view_render.go
index 033c0b9b79..b600077edc 100644
--- a/kernel/model/attribute_view_render.go
+++ b/kernel/model/attribute_view_render.go
@@ -88,6 +88,11 @@ func renderAttributeView(attrView *av.AttributeView, nodeID, viewID, query strin
}
func renderAttributeViewGroups(viewable av.Viewable, attrView *av.AttributeView, view *av.View, query string, page, pageSize int, groupPaging map[string]interface{}) (err error) {
+ groupKey := view.GetGroupKey(attrView)
+ if nil == groupKey {
+ return
+ }
+
// 当前日期可能会变,所以如果是按日期分组则需要重新生成分组
if isGroupByDate(view) {
createdDate := time.UnixMilli(view.GroupCreated).Format("2006-01-02")
@@ -97,9 +102,10 @@ func renderAttributeViewGroups(viewable av.Viewable, attrView *av.AttributeView,
}
}
- groupKey := view.GetGroupKey(attrView)
- if nil == groupKey {
- return
+ // 如果是按模板分组则需要重新生成分组
+ if isGroupByTemplate(attrView, view) {
+ regenAttrViewGroups(attrView)
+ av.SaveAttributeView(attrView)
}
// 如果存在分组的话渲染分组视图
@@ -352,6 +358,18 @@ func isGroupByDate(view *av.View) bool {
return av.GroupMethodDateDay == view.Group.Method || av.GroupMethodDateWeek == view.Group.Method || av.GroupMethodDateMonth == view.Group.Method || av.GroupMethodDateYear == view.Group.Method || av.GroupMethodDateRelative == view.Group.Method
}
+func isGroupByTemplate(attrView *av.AttributeView, view *av.View) bool {
+ if nil == view.Group {
+ return false
+ }
+
+ groupKey := view.GetGroupKey(attrView)
+ if nil == groupKey {
+ return false
+ }
+ return av.KeyTypeTemplate == groupKey.Type
+}
+
func renderViewableInstance(viewable av.Viewable, view *av.View, attrView *av.AttributeView, page, pageSize int) (err error) {
if nil == viewable {
err = av.ErrViewNotFound