Rework LLM classification around user categories
Move category CRUD into the config route so renames sync historical deals, feed per-user categories into the LLM prompt, cache clients per user, and drop the separate classify route.
This commit is contained in:
@@ -67,9 +67,14 @@ router.get("/", (req, res) => {
|
||||
"counterparty",
|
||||
"category",
|
||||
"match_count",
|
||||
"abs_amount",
|
||||
];
|
||||
const safeSort = allowedSort.includes(sort_by) ? sort_by : "deal_date";
|
||||
const safeOrder = sort_order === "ASC" ? "ASC" : "DESC";
|
||||
// abs_amount:按金额绝对值排序(大额确认用,收/支混排时按体量从大到小)
|
||||
const sortExpr =
|
||||
safeSort === "abs_amount" ? "ABS(d.amount)" : `d.${safeSort}`;
|
||||
const tieBreaker = safeSort === "abs_amount" ? ", d.id DESC" : "";
|
||||
|
||||
const total = db
|
||||
.prepare(`SELECT COUNT(*) as c FROM deals d ${where}`)
|
||||
@@ -90,7 +95,7 @@ router.get("/", (req, res) => {
|
||||
LEFT JOIN transactions t ON t.id = dt.transaction_id
|
||||
${where}
|
||||
GROUP BY d.id
|
||||
ORDER BY d.${safeSort} ${safeOrder}
|
||||
ORDER BY ${sortExpr} ${safeOrder}${tieBreaker}
|
||||
LIMIT ? OFFSET ?
|
||||
`,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user