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
This commit is contained in:
parent
31d6cb6f86
commit
a1d2546117
4
db.go
4
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 {
|
||||
|
|
|
|||
2
main.go
2
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",
|
||||
|
|
|
|||
|
|
@ -8,7 +8,10 @@
|
|||
<p class="font-medium text-gray-900 dark:text-white truncate text-sm">{{.Title}}</p>
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400 truncate">{{truncate .Summary 50}}</p>
|
||||
</div>
|
||||
<span class="ml-2 text-xs text-gray-400">{{title .Category}}</span>
|
||||
<div class="ml-2 text-right flex-shrink-0">
|
||||
<span class="text-xs text-gray-400 block">{{title .Category}}</span>
|
||||
{{if .ProcessedAt}}<span class="text-xs text-gray-400 block">{{formatDate .ProcessedAt}}</span>{{end}}
|
||||
</div>
|
||||
</a>
|
||||
{{end}}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -56,7 +56,9 @@
|
|||
{{title .Type}}
|
||||
</span>
|
||||
{{end}}
|
||||
{{if .Date}}
|
||||
{{if .ProcessedAt}}
|
||||
<span class="text-xs text-gray-500 dark:text-gray-400">📅 {{formatDateTime .ProcessedAt}}</span>
|
||||
{{else if .Date}}
|
||||
<span class="text-xs text-gray-500 dark:text-gray-400">{{formatDate .Date}}</span>
|
||||
{{end}}
|
||||
{{if .Score}}
|
||||
|
|
|
|||
Loading…
Reference in New Issue