Skip to content

Commit 211648b

Browse files
committed
🎨 Database grouping by field siyuan-note#10964
1 parent 3d7191b commit 211648b

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

kernel/model/attribute_view.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,7 @@ func genAttrViewViewGroups(view *av.View, attrView *av.AttributeView) {
17811781
} else {
17821782
if av.GroupMethodDateRelative == view.Group.Method {
17831783
var relativeDateGroups []*av.View
1784-
var last30Days, last7Days, yesterday, today, tomorrow, next7Days, next30Days *av.View
1784+
var last30Days, last7Days, yesterday, today, tomorrow, next7Days, next30Days, defaultGroup *av.View
17851785
for _, groupView := range view.Groups {
17861786
_, err := time.Parse("2006-01", groupView.GroupValue)
17871787
if nil == err { // 如果能解析出来说明是 30 天之前或 30 天之后的分组形式
@@ -1802,6 +1802,8 @@ func genAttrViewViewGroups(view *av.View, attrView *av.AttributeView) {
18021802
next7Days = groupView
18031803
case groupValueNext30Days:
18041804
next30Days = groupView
1805+
case groupValueDefault:
1806+
defaultGroup = groupView
18051807
}
18061808
}
18071809
}
@@ -1847,6 +1849,14 @@ func genAttrViewViewGroups(view *av.View, attrView *av.AttributeView) {
18471849
for _, g := range lastNext30Days {
18481850
relativeDateGroups = util.InsertElem(relativeDateGroups, startIdx, g)
18491851
}
1852+
if nil != defaultGroup {
1853+
relativeDateGroups = append([]*av.View{defaultGroup}, relativeDateGroups...)
1854+
}
1855+
1856+
if av.GroupOrderDesc == view.Group.Order {
1857+
slices.Reverse(relativeDateGroups)
1858+
}
1859+
18501860
view.Groups = relativeDateGroups
18511861
} else {
18521862
sort.SliceStable(view.Groups, func(i, j int) bool {

0 commit comments

Comments
 (0)