feat: add recent tags section to items page

Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-29 12:20:34 -03:00
parent 467e91ab47
commit eb42b207f0

View File

@@ -101,6 +101,32 @@ fn build_item_list(conn: &Connection, params: &ListQueryParams, columns: &[Colum
html.push_str("<h1>Items</h1>");
html.push_str("<p><a href=\"/swagger\">API Documentation</a></p>");
// Add recent tags section
html.push_str("<h2>Recent Tags</h2>");
let recent_tags_query = "
SELECT DISTINCT t.name
FROM tags t
JOIN item_tags it ON t.id = it.tag_id
ORDER BY it.id DESC
LIMIT 20
";
let mut stmt = conn.prepare(recent_tags_query)?;
let tag_iter = stmt.query_map([], |row| {
Ok(row.get::<_, String>(0)?)
})?;
let recent_tags: Vec<String> = tag_iter.collect::<Result<Vec<_>, _>>()?;
if recent_tags.is_empty() {
html.push_str("<p>No tags found</p>");
} else {
html.push_str("<p>");
for tag in recent_tags {
html.push_str(&format!("<a href=\"/?tags={}\" style=\"margin-right: 8px;\">{}</a>", tag, tag));
}
html.push_str("</p>");
}
// Start table
html.push_str("<table>");