mirror of
https://github.com/clucraft/PriceGhost.git
synced 2026-05-18 13:55:16 +02:00
Add target price alerts, historical low indicator, bulk actions, and dashboard summary
Features: - Target price alerts: Set a specific price target and get notified when reached - Historical low indicator: Badge showing when current price is at/near all-time low - Bulk actions: Select multiple products to delete at once - Dashboard summary: Shows total products, items at lowest price, at target, biggest drops Backend changes: - Add target_price column to products table - Add target_price notification type with Telegram/Discord support - Include min_price in product queries for historical low detection - Update scheduler to check target price conditions Frontend changes: - Add target price input to ProductDetail notification settings - Show target price badge on product cards - Add "Lowest Price" and "Near Low" badges to product cards - Add bulk selection mode with checkboxes - Add dashboard summary cards at top of product list Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
2acc47c21c
commit
a85e22d8bc
9 changed files with 454 additions and 5 deletions
|
|
@ -91,6 +91,34 @@ async function checkPrices(): Promise<void> {
|
|||
}
|
||||
}
|
||||
|
||||
// Check for target price notification
|
||||
if (product.target_price) {
|
||||
const newPrice = scrapedData.price.price;
|
||||
const targetPrice = parseFloat(String(product.target_price));
|
||||
const oldPrice = latestPrice ? parseFloat(String(latestPrice.price)) : null;
|
||||
|
||||
// Only notify if price just dropped to or below target (wasn't already below)
|
||||
if (newPrice <= targetPrice && (!oldPrice || oldPrice > targetPrice)) {
|
||||
try {
|
||||
const userSettings = await userQueries.getNotificationSettings(product.user_id);
|
||||
if (userSettings) {
|
||||
const payload: NotificationPayload = {
|
||||
productName: product.name || 'Unknown Product',
|
||||
productUrl: product.url,
|
||||
type: 'target_price',
|
||||
newPrice: newPrice,
|
||||
currency: scrapedData.price.currency,
|
||||
targetPrice: targetPrice,
|
||||
};
|
||||
await sendNotifications(userSettings, payload);
|
||||
console.log(`Target price notification sent for product ${product.id}: ${newPrice} <= ${targetPrice}`);
|
||||
}
|
||||
} catch (notifyError) {
|
||||
console.error(`Failed to send target price notification for product ${product.id}:`, notifyError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await priceHistoryQueries.create(
|
||||
product.id,
|
||||
scrapedData.price.price,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue