From a1d2546117bbaf54998f0ac65e16f684e44c0e71 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 31 Mar 2026 13:34:54 -0400 Subject: [PATCH] Search: sort by timestamp desc, display dates in results - FTS search results now ORDER BY processed_at DESC (was rank) - Full search page shows processed timestamp with formatDateTime - Quick search dropdown shows formatted date next to category - Fixed formatDate to handle timezone-aware timestamps --- db.go | 4 ++-- main.go | 2 ++ templates/partials/document-list.html | 5 ++++- templates/search.html | 4 +++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/db.go b/db.go index a218500..b14f7be 100644 --- a/db.go +++ b/db.go @@ -337,7 +337,7 @@ func SearchDocuments(query string, limit int) ([]Document, error) { FROM documents d JOIN documents_fts fts ON d.id = fts.id WHERE documents_fts MATCH ? - ORDER BY rank + ORDER BY d.processed_at DESC LIMIT ? `, query, limit) @@ -731,7 +731,7 @@ func SearchDocumentsWithFullText(query string, limit int) ([]Document, error) { FROM documents d JOIN documents_fts fts ON d.id = fts.id WHERE documents_fts MATCH ? - ORDER BY rank + ORDER BY d.processed_at DESC LIMIT ? `, query, limit) if err != nil { diff --git a/main.go b/main.go index 8c8a7d2..c432a10 100644 --- a/main.go +++ b/main.go @@ -157,6 +157,8 @@ func categoryIcon(cat string) string { func formatDate(s string) string { formats := []string{ + "2006-01-02T15:04:05-07:00", + "2006-01-02T15:04:05.999999-07:00", "2006-01-02T15:04:05.999999", "2006-01-02T15:04:05", "2006-01-02", diff --git a/templates/partials/document-list.html b/templates/partials/document-list.html index 526cb65..19ee29b 100644 --- a/templates/partials/document-list.html +++ b/templates/partials/document-list.html @@ -8,7 +8,10 @@

{{.Title}}

{{truncate .Summary 50}}

- {{title .Category}} +
+ {{title .Category}} + {{if .ProcessedAt}}{{formatDate .ProcessedAt}}{{end}} +
{{end}} diff --git a/templates/search.html b/templates/search.html index f0cec7b..dcdd732 100644 --- a/templates/search.html +++ b/templates/search.html @@ -56,7 +56,9 @@ {{title .Type}} {{end}} - {{if .Date}} + {{if .ProcessedAt}} + 📅 {{formatDateTime .ProcessedAt}} + {{else if .Date}} {{formatDate .Date}} {{end}} {{if .Score}}