Files
tenderpilot/fix-urls.mjs

30 lines
908 B
JavaScript
Raw Permalink Normal View History

import pg from 'pg';
const pool = new pg.Pool({
connectionString: 'postgresql://tenderpilot:jqrmilIBr6imtT0fKS01@localhost:5432/tenderpilot'
});
console.log('Fixing find_tender URLs (removing query params)...');
const result = await pool.query(
"UPDATE tenders SET notice_url = split_part(notice_url, '?', 1) WHERE source = 'find_tender' AND notice_url LIKE '%?%' RETURNING id, notice_url"
);
console.log(`✓ Fixed ${result.rowCount} find_tender URLs`);
if (result.rows.length > 0) {
console.log('Sample fixed URLs:');
result.rows.slice(0, 3).forEach(row => {
console.log(` - ${row.notice_url}`);
});
}
console.log('\nDeleting TED demo data...');
const deleteResult = await pool.query(
"DELETE FROM tenders WHERE source = 'ted_eu' RETURNING id"
);
console.log(`✓ Deleted ${deleteResult.rowCount} TED demo records`);
console.log('\nDatabase cleanup complete!');
await pool.end();