const fs = require('fs');
let code = fs.readFileSync('seo-server.js', 'utf8');

// Replace the entire task lookup query with a cast-to-text approach
code = code.replace(
  `const { data: tasks, error } = await supabase
      .from('tasks')
      .select('id, title, category, budget, max_workers, status, created_at, description, expires_at')
      .ilike('id', \`\${prefix}%\`).in('status', ['open', 'active', 'expired', 'closed'])
      .limit(1);`,
  `const { data: tasks, error } = await supabase
      .from('tasks')
      .select('id, title, category, budget, max_workers, status, created_at, description, expires_at')
      .filter('id::text', 'ilike', \`\${prefix}%\`)
      .limit(1);`
);

fs.writeFileSync('seo-server.js', code);
console.log('Fixed!');
