feat: enhance Stalker functionality with additional product details and analysis capabilities
This commit is contained in:
@@ -82,6 +82,18 @@ type StalkerProductRecord = {
|
||||
can_sell: number;
|
||||
sellability_status: string;
|
||||
sellability_reason: string | null;
|
||||
product_title: string | null;
|
||||
brand: string | null;
|
||||
category_tree: string | null;
|
||||
current_price: number | null;
|
||||
avg_price_90d: number | null;
|
||||
sales_rank: number | null;
|
||||
monthly_sold: number | null;
|
||||
seller_count: number | null;
|
||||
amazon_is_seller: number | null;
|
||||
verdict: string | null;
|
||||
confidence: number | null;
|
||||
reasoning: string | null;
|
||||
last_seen_at: string;
|
||||
};
|
||||
|
||||
@@ -840,9 +852,16 @@ function parseStalkerProductFilters(filters: URLSearchParams) {
|
||||
if (q) {
|
||||
const wildcard = `%${q}%`;
|
||||
conditions.push(
|
||||
"(inv.asin LIKE ? OR s.seller_id LIKE ? OR s.seller_name LIKE ?)",
|
||||
`(
|
||||
inv.asin LIKE ?
|
||||
OR inv.product_title LIKE ?
|
||||
OR inv.brand LIKE ?
|
||||
OR inv.category_tree LIKE ?
|
||||
OR s.seller_id LIKE ?
|
||||
OR s.seller_name LIKE ?
|
||||
)`,
|
||||
);
|
||||
params.push(wildcard, wildcard, wildcard);
|
||||
params.push(wildcard, wildcard, wildcard, wildcard, wildcard, wildcard);
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -860,9 +879,19 @@ function parseStalkerProductSort(sortParam: string | null): string {
|
||||
"rating",
|
||||
"rating_count",
|
||||
"asin",
|
||||
"product_title",
|
||||
"brand",
|
||||
"current_price",
|
||||
"avg_price_90d",
|
||||
"sales_rank",
|
||||
"monthly_sold",
|
||||
"seller_count",
|
||||
"amazon_is_seller",
|
||||
"verdict",
|
||||
"confidence",
|
||||
"last_seen_at",
|
||||
]);
|
||||
return parseSort(sortParam, allowedSort, "last_seen_at DESC, asin ASC");
|
||||
return parseSort(sortParam, allowedSort, "monthly_sold DESC, last_seen_at DESC, asin ASC");
|
||||
}
|
||||
|
||||
function getStalkerProducts(filters: URLSearchParams) {
|
||||
@@ -887,10 +916,23 @@ function getStalkerProducts(filters: URLSearchParams) {
|
||||
inv.can_sell,
|
||||
inv.sellability_status,
|
||||
inv.sellability_reason,
|
||||
inv.product_title,
|
||||
inv.brand,
|
||||
inv.category_tree,
|
||||
inv.current_price,
|
||||
inv.avg_price_90d,
|
||||
inv.sales_rank,
|
||||
inv.monthly_sold,
|
||||
inv.seller_count,
|
||||
inv.amazon_is_seller,
|
||||
analysis.verdict,
|
||||
analysis.confidence,
|
||||
analysis.reasoning,
|
||||
inv.last_seen_at
|
||||
FROM stalker_seller_inventory inv
|
||||
JOIN stalker_runs r ON r.id = inv.run_id
|
||||
JOIN stalker_sellers s ON s.seller_id = inv.seller_id
|
||||
LEFT JOIN product_analysis_results analysis ON analysis.asin = inv.asin
|
||||
${where}
|
||||
`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user