From d986cfc9119b48160da5babaace8a9df9db2e62c Mon Sep 17 00:00:00 2001
From: Daniel <845765@qq.com>
Date: Sun, 16 Feb 2025 15:30:47 +0800
Subject: [PATCH 1/5] :art: Improve database date field relative between filter
https://github.com/siyuan-note/siyuan/issues/14091
---
kernel/av/filter.go | 36 +++++++++++++++++++++++++++++++-----
1 file changed, 31 insertions(+), 5 deletions(-)
diff --git a/kernel/av/filter.go b/kernel/av/filter.go
index f386691d2..bac2de516 100644
--- a/kernel/av/filter.go
+++ b/kernel/av/filter.go
@@ -592,7 +592,23 @@ func filterRelativeTime(valueMills int64, valueIsNotEmpty bool, operator FilterO
return valueTime.Before(otherValueEnd) || valueTime.Equal(otherValueEnd)
case FilterOperatorIsBetween:
if RelativeDateDirectionBefore == direction {
- if RelativeDateDirectionBefore == direction2 || RelativeDateDirectionAfter == direction2 {
+ if RelativeDateDirectionBefore == direction2 {
+ var leftStart, rightEnd time.Time
+ if otherValueStart.Before(otherValueStart2) {
+ leftStart = otherValueStart
+ } else {
+ leftStart = otherValueStart2
+ }
+ if otherValueEnd.Before(otherValueStart2) {
+ rightEnd = otherValueEnd
+ } else {
+ rightEnd = otherValueStart2
+ }
+ return (valueTime.After(leftStart) || valueTime.Equal(leftStart)) && (valueTime.Before(rightEnd) || valueTime.Equal(rightEnd))
+ } else if RelativeDateDirectionThis == direction2 {
+ return ((valueTime.After(otherValueStart) || valueTime.Equal(otherValueStart)) && (valueTime.Before(otherValueEnd) || valueTime.Equal(otherValueEnd))) ||
+ ((valueTime.After(otherValueStart2) || valueTime.Equal(otherValueStart2)) && (valueTime.Before(otherValueEnd2) || valueTime.Equal(otherValueEnd2)))
+ } else if RelativeDateDirectionAfter == direction2 {
var leftStart, rightEnd time.Time
if otherValueStart.Before(otherValueStart2) {
leftStart = otherValueStart
@@ -605,15 +621,12 @@ func filterRelativeTime(valueMills int64, valueIsNotEmpty bool, operator FilterO
rightEnd = otherValueEnd
}
return (valueTime.After(leftStart) || valueTime.Equal(leftStart)) && (valueTime.Before(rightEnd) || valueTime.Equal(rightEnd))
- } else if RelativeDateDirectionThis == direction2 {
- return ((valueTime.After(otherValueStart) || valueTime.Equal(otherValueStart)) && (valueTime.Before(otherValueEnd) || valueTime.Equal(otherValueEnd))) ||
- ((valueTime.After(otherValueStart2) || valueTime.Equal(otherValueStart2)) && (valueTime.Before(otherValueEnd2) || valueTime.Equal(otherValueEnd2)))
}
} else if RelativeDateDirectionThis == direction {
return ((valueTime.After(otherValueStart) || valueTime.Equal(otherValueStart)) && (valueTime.Before(otherValueEnd) || valueTime.Equal(otherValueEnd))) ||
((valueTime.After(otherValueStart2) || valueTime.Equal(otherValueStart2)) && (valueTime.Before(otherValueEnd2) || valueTime.Equal(otherValueEnd2)))
} else if RelativeDateDirectionAfter == direction {
- if RelativeDateDirectionBefore == direction2 || RelativeDateDirectionAfter == direction2 {
+ if RelativeDateDirectionBefore == direction2 {
var leftStart, rightEnd time.Time
if otherValueStart.Before(otherValueStart2) {
leftStart = otherValueStart
@@ -629,6 +642,19 @@ func filterRelativeTime(valueMills int64, valueIsNotEmpty bool, operator FilterO
} else if RelativeDateDirectionThis == direction2 {
return ((valueTime.After(otherValueStart) || valueTime.Equal(otherValueStart)) && (valueTime.Before(otherValueEnd) || valueTime.Equal(otherValueEnd))) ||
((valueTime.After(otherValueStart2) || valueTime.Equal(otherValueStart2)) && (valueTime.Before(otherValueEnd2) || valueTime.Equal(otherValueEnd2)))
+ } else if RelativeDateDirectionAfter == direction2 {
+ var leftStart, rightEnd time.Time
+ if otherValueEnd.Before(otherValueEnd2) {
+ leftStart = otherValueEnd
+ } else {
+ leftStart = otherValueEnd2
+ }
+ if otherValueEnd.After(otherValueEnd2) {
+ rightEnd = otherValueEnd
+ } else {
+ rightEnd = otherValueEnd2
+ }
+ return (valueTime.After(leftStart) || valueTime.Equal(leftStart)) && (valueTime.Before(rightEnd) || valueTime.Equal(rightEnd))
}
}
return false
From d97899668b918caa205ffb34574826bbc8537f11 Mon Sep 17 00:00:00 2001
From: Daniel <845765@qq.com>
Date: Sun, 16 Feb 2025 15:43:12 +0800
Subject: [PATCH 2/5] :art: Improve database date field relative between filter
https://github.com/siyuan-note/siyuan/issues/14091
---
app/src/protyle/render/av/filter.ts | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/src/protyle/render/av/filter.ts b/app/src/protyle/render/av/filter.ts
index a1b598519..b4bd14cb4 100644
--- a/app/src/protyle/render/av/filter.ts
+++ b/app/src/protyle/render/av/filter.ts
@@ -426,7 +426,7 @@ export const setFilter = async (options: {
-
+
-
+