@@ -2472,10 +2472,6 @@ app.post('/api/admin/run-scraper', authenticate, async (req, res) => {
24722472 ) ,
24732473 ] ;
24742474
2475- const csvPath = path . join ( __dirname , '../scripts/scraper_diff.csv' ) ;
2476- fs . writeFileSync ( csvPath , csvLines . join ( '\n' ) , 'utf8' ) ;
2477- console . log ( `[run-scraper] Diff CSV written to ${ csvPath } ` ) ;
2478-
24792475 res . status ( 200 ) . json ( {
24802476 total : scraped . length ,
24812477 newCount,
@@ -2491,40 +2487,6 @@ app.post('/api/admin/run-scraper', authenticate, async (req, res) => {
24912487 }
24922488} ) ;
24932489
2494- /**
2495- * Download Scraper Diff CSV - Returns the last scraper_diff.csv written by
2496- * POST /api/admin/run-scraper.
2497- *
2498- * @route GET /api/admin/scraper-results.csv
2499- *
2500- * @status
2501- * - 200: CSV file download
2502- * - 401: Authentication failed
2503- * - 403: Unauthorized - Admin access required
2504- * - 404: No scraper results found — run the scraper first
2505- * - 500: Server error
2506- */
2507- app . get ( '/api/admin/scraper-results.csv' , authenticate , async ( req , res ) => {
2508- if ( ! req . user ) throw new Error ( 'Not authenticated' ) ;
2509-
2510- const { email } = req . user ;
2511- if ( ! email || ! admins . includes ( email ) ) {
2512- res . status ( 403 ) . send ( 'Unauthorized: Admin access required' ) ;
2513- return ;
2514- }
2515-
2516- const csvPath = path . join ( __dirname , '../scripts/scraper_diff.csv' ) ;
2517-
2518- if ( ! fs . existsSync ( csvPath ) ) {
2519- res . status ( 404 ) . send ( 'No scraper results found. Run POST /api/admin/run-scraper first.' ) ;
2520- return ;
2521- }
2522-
2523- res . setHeader ( 'Content-Type' , 'text/csv' ) ;
2524- res . setHeader ( 'Content-Disposition' , 'attachment; filename="scraper_diff.csv"' ) ;
2525- fs . createReadStream ( csvPath ) . pipe ( res ) ;
2526- } ) ;
2527-
25282490/**
25292491 * Apply Scraper Changes - Takes an array of reviewed/edited diff rows and writes
25302492 * the approved values to the corresponding Firestore building documents.
0 commit comments