ux improved
This commit is contained in:
@@ -146,6 +146,35 @@ export async function searchSnapshotItems({ tenantId, q = "", limit = 12 }) {
|
||||
const query = String(q || "").trim();
|
||||
if (!query) return { items: [], source: "snapshot" };
|
||||
const like = `%${query}%`;
|
||||
// #region agent log
|
||||
const totalSnapshot = await pool.query(
|
||||
"select count(*)::int as cnt from woo_products_snapshot where tenant_id=$1",
|
||||
[tenantId]
|
||||
);
|
||||
const totalSellable = await pool.query(
|
||||
"select count(*)::int as cnt from sellable_items where tenant_id=$1",
|
||||
[tenantId]
|
||||
);
|
||||
fetch("http://127.0.0.1:7242/ingest/86c7b1cd-c414-4eae-852c-08e57e562b3b", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
sessionId: "debug-session",
|
||||
runId: "pre-fix",
|
||||
hypothesisId: "H8",
|
||||
location: "wooSnapshot.js:152",
|
||||
message: "snapshot_counts",
|
||||
data: {
|
||||
tenantId: tenantId || null,
|
||||
total_snapshot: totalSnapshot?.rows?.[0]?.cnt ?? null,
|
||||
total_sellable: totalSellable?.rows?.[0]?.cnt ?? null,
|
||||
query,
|
||||
limit: lim,
|
||||
},
|
||||
timestamp: Date.now(),
|
||||
}),
|
||||
}).catch(() => {});
|
||||
// #endregion
|
||||
const sql = `
|
||||
select *
|
||||
from sellable_items
|
||||
@@ -155,6 +184,25 @@ export async function searchSnapshotItems({ tenantId, q = "", limit = 12 }) {
|
||||
limit $3
|
||||
`;
|
||||
const { rows } = await pool.query(sql, [tenantId, like, lim]);
|
||||
// #region agent log
|
||||
fetch("http://127.0.0.1:7242/ingest/86c7b1cd-c414-4eae-852c-08e57e562b3b", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
sessionId: "debug-session",
|
||||
runId: "pre-fix",
|
||||
hypothesisId: "H8",
|
||||
location: "wooSnapshot.js:168",
|
||||
message: "snapshot_search_result",
|
||||
data: {
|
||||
query,
|
||||
found: rows.length,
|
||||
sample_names: rows.slice(0, 3).map((r) => r?.name).filter(Boolean),
|
||||
},
|
||||
timestamp: Date.now(),
|
||||
}),
|
||||
}).catch(() => {});
|
||||
// #endregion
|
||||
return { items: rows.map(snapshotRowToItem), source: "snapshot" };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user