Files
cannaiq/backend/archive/test-scrape-flower.ts
Kelly d91c55a344 feat: Add stale process monitor, users route, landing page, archive old scripts
- Add backend stale process monitoring API (/api/stale-processes)
- Add users management route
- Add frontend landing page and stale process monitor UI on /scraper-tools
- Move old development scripts to backend/archive/
- Update frontend build with new features

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 04:07:31 -07:00

40 lines
1.2 KiB
TypeScript

import { scrapeCategory, saveProducts } from './src/services/scraper';
import { pool } from './src/db/migrate';
async function test() {
try {
console.log('Testing scraping Flower category (ID 85) for store 18...\n');
const storeId = 18;
const categoryId = 85; // Flower category
console.log('Step 1: Scraping products from Flower category...');
const products = await scrapeCategory(storeId, categoryId);
console.log(`\nStep 2: Scraped ${products.length} products. Saving to database...`);
await saveProducts(storeId, categoryId, products);
console.log('\nStep 3: Checking brands extracted from products...');
const brandsResult = await pool.query(`
SELECT DISTINCT brand
FROM products
WHERE store_id = $1 AND category_id = $2 AND brand IS NOT NULL
ORDER BY brand
`, [storeId, categoryId]);
console.log(`\nFound ${brandsResult.rows.length} unique brands:`);
brandsResult.rows.forEach(row => {
console.log(` - ${row.brand}`);
});
await pool.end();
console.log('\n✅ Test completed successfully!');
process.exit(0);
} catch (error) {
console.error('\n❌ Error:', error);
process.exit(1);
}
}
test();