A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
fix(search): make before: include the whole day (#3255)
Mohamed Bassemc3120be604c3
diff --git a/packages/trpc/lib/__tests__/search.test.ts b/packages/trpc/lib/__tests__/search.test.tsindex faac4f26..f0113c64 100644--- a/packages/trpc/lib/__tests__/search.test.ts+++ b/packages/trpc/lib/__tests__/search.test.ts@@ -61,7 +61,7 @@ beforeEach(async () => {userId: testUserId,archived: true,favourited: true,- createdAt: new Date("2024-01-02"),+ createdAt: new Date("2024-01-02T10:00:00Z"),title: "example domain page",note: "",},diff --git a/packages/trpc/lib/search.ts b/packages/trpc/lib/search.tsindex bff713a3..e7b0924a 100644--- a/packages/trpc/lib/search.ts+++ b/packages/trpc/lib/search.ts@@ -226,8 +226,13 @@ export async function getBookmarksConditionFromMatcher(return comp(bookmarks.createdAt, matcher.dateAfter);}case "dateBefore": {- const comp = matcher.inverse ? gt : lte;- return comp(bookmarks.createdAt, matcher.dateBefore);+ // `before:<date>` is inclusive of the whole day, so compare against+ // the start of the following day.+ const endOfDay = new Date(+ matcher.dateBefore.getTime() + 24 * 60 * 60 * 1000,+ );+ const comp = matcher.inverse ? gte : lt;+ return comp(bookmarks.createdAt, endOfDay);}case "age": {const comp = matcher.relativeDate.direction === "newer" ? gte : lt;