fix: add debug logging for tag counts per item

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:23:03 -03:00
parent 0c9e861307
commit 2b0e958b1f

View File

@@ -5,6 +5,7 @@ use axum::{
extract::{Path, Query, State}, extract::{Path, Query, State},
response::{Html, Response}, response::{Html, Response},
}; };
use log::debug;
use rusqlite::Connection; use rusqlite::Connection;
use serde::Deserialize; use serde::Deserialize;
use crate::config::ColumnConfig; use crate::config::ColumnConfig;
@@ -94,6 +95,13 @@ fn build_item_list(conn: &Connection, params: &ListQueryParams, columns: &[Colum
let tags_map = db::get_tags_for_items(conn, &item_ids)?; let tags_map = db::get_tags_for_items(conn, &item_ids)?;
let meta_map = db::get_meta_for_items(conn, &item_ids)?; let meta_map = db::get_meta_for_items(conn, &item_ids)?;
// Debug: print number of tags per item
for item_id in &item_ids {
if let Some(tags) = tags_map.get(item_id) {
debug!("Item {} has {} tags: {:?}", item_id, tags.len(), tags);
}
}
let mut html = String::new(); let mut html = String::new();
html.push_str("<html><head><title>Items</title>"); html.push_str("<html><head><title>Items</title>");
html.push_str("<link rel=\"stylesheet\" href=\"/style.css\">"); html.push_str("<link rel=\"stylesheet\" href=\"/style.css\">");
@@ -104,7 +112,7 @@ fn build_item_list(conn: &Connection, params: &ListQueryParams, columns: &[Colum
// Add recent tags section using the items we already have // Add recent tags section using the items we already have
html.push_str("<h2>Recent Tags</h2>"); html.push_str("<h2>Recent Tags</h2>");
// Collect all tags from the items, keeping track of their timestamps // Collect all tags from all items, keeping track of their timestamps
let mut all_tags_with_time: Vec<(String, chrono::DateTime<chrono::Utc>)> = Vec::new(); let mut all_tags_with_time: Vec<(String, chrono::DateTime<chrono::Utc>)> = Vec::new();
for item in &sorted_items { for item in &sorted_items {
if let Some(item_id) = item.id { if let Some(item_id) = item.id {
@@ -116,7 +124,7 @@ fn build_item_list(conn: &Connection, params: &ListQueryParams, columns: &[Colum
} }
} }
// Sort by timestamp descending and deduplicate // Sort by timestamp descending (most recent first)
all_tags_with_time.sort_by(|a, b| b.1.cmp(&a.1)); all_tags_with_time.sort_by(|a, b| b.1.cmp(&a.1));
// Get unique tags in order of most recent appearance // Get unique tags in order of most recent appearance
@@ -176,10 +184,11 @@ fn build_item_list(conn: &Connection, params: &ListQueryParams, columns: &[Colum
"time" => item.ts.format("%Y-%m-%d %H:%M:%S").to_string(), "time" => item.ts.format("%Y-%m-%d %H:%M:%S").to_string(),
"size" => item.size.map(|s| s.to_string()).unwrap_or_default(), "size" => item.size.map(|s| s.to_string()).unwrap_or_default(),
"tags" => { "tags" => {
tags.iter() // Make sure we're using all tags for the item
let tag_links: Vec<String> = tags.iter()
.map(|t| format!("<a href=\"/?tags={}\">{}</a>", t.name, t.name)) .map(|t| format!("<a href=\"/?tags={}\">{}</a>", t.name, t.name))
.collect::<Vec<_>>() .collect();
.join(", ") tag_links.join(", ")
}, },
_ => { _ => {
if column.name.starts_with("meta:") { if column.name.starts_with("meta:") {