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
|
FROM documents d
|
||||||
JOIN documents_fts fts ON d.id = fts.id
|
JOIN documents_fts fts ON d.id = fts.id
|
||||||
WHERE documents_fts MATCH ?
|
WHERE documents_fts MATCH ?
|
||||||
ORDER BY rank
|
ORDER BY d.processed_at DESC
|
||||||
LIMIT ?
|
LIMIT ?
|
||||||
`, query, limit)
|
`, query, limit)
|
||||||
|
|
||||||
|
|
@ -731,7 +731,7 @@ func SearchDocumentsWithFullText(query string, limit int) ([]Document, error) {
|
||||||
FROM documents d
|
FROM documents d
|
||||||
JOIN documents_fts fts ON d.id = fts.id
|
JOIN documents_fts fts ON d.id = fts.id
|
||||||
WHERE documents_fts MATCH ?
|
WHERE documents_fts MATCH ?
|
||||||
ORDER BY rank
|
ORDER BY d.processed_at DESC
|
||||||
LIMIT ?
|
LIMIT ?
|
||||||
`, query, limit)
|
`, query, limit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
2
main.go
2
main.go
|
|
@ -157,6 +157,8 @@ func categoryIcon(cat string) string {
|
||||||
|
|
||||||
func formatDate(s string) string {
|
func formatDate(s string) string {
|
||||||
formats := []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.999999",
|
||||||
"2006-01-02T15:04:05",
|
"2006-01-02T15:04:05",
|
||||||
"2006-01-02",
|
"2006-01-02",
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,10 @@
|
||||||
<p class="font-medium text-gray-900 dark:text-white truncate text-sm">{{.Title}}</p>
|
<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>
|
<p class="text-xs text-gray-500 dark:text-gray-400 truncate">{{truncate .Summary 50}}</p>
|
||||||
</div>
|
</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>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,9 @@
|
||||||
{{title .Type}}
|
{{title .Type}}
|
||||||
</span>
|
</span>
|
||||||
{{end}}
|
{{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>
|
<span class="text-xs text-gray-500 dark:text-gray-400">{{formatDate .Date}}</span>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if .Score}}
|
{{if .Score}}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue