fixes
This commit is contained in:
@@ -46,9 +46,16 @@ class AdzunaTransformer implements JobTransformer
|
||||
|
||||
private function sanitizeDescription(string $description): string
|
||||
{
|
||||
$clean = strip_tags($description);
|
||||
// Adzuna returns truncated descriptions with ellipsis (...)
|
||||
// Keep the description as-is but strip excessive HTML while preserving basic formatting
|
||||
$clean = strip_tags($description, '<p><br><ul><ol><li><strong><b><em><i><h1><h2><h3><h4>');
|
||||
$clean = html_entity_decode($clean, ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
$clean = preg_replace('/\s+/', ' ', $clean);
|
||||
|
||||
// Convert multiple spaces to single space but preserve newlines
|
||||
$clean = preg_replace('/[^\S\n]+/', ' ', $clean);
|
||||
|
||||
// Note: Adzuna API only provides truncated descriptions in search results.
|
||||
// Full descriptions would require individual job detail API calls.
|
||||
return trim($clean);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,9 +70,32 @@ class RemotiveTransformer implements JobTransformer
|
||||
return null;
|
||||
}
|
||||
|
||||
// Try to extract numbers from salary string
|
||||
if (preg_match_all('/[\d,]+/', $salary, $matches)) {
|
||||
$numbers = array_map(fn($n) => (float) str_replace(',', '', $n), $matches[0]);
|
||||
// Normalize the salary string
|
||||
$salary = strtolower($salary);
|
||||
|
||||
// Check if it's hourly rate - if so, convert to annual (assuming 40hr/week * 52 weeks = 2080 hours/year)
|
||||
$isHourly = str_contains($salary, '/hour') || str_contains($salary, 'per hour') || str_contains($salary, '/hr');
|
||||
|
||||
// Try to extract numbers with optional k/K suffix
|
||||
// Pattern: number followed by optional comma-separated digits, then optional 'k'
|
||||
if (preg_match_all('/\$?\s*([\d,]+)\s*([kK])?/', $salary, $matches, PREG_SET_ORDER)) {
|
||||
$numbers = [];
|
||||
|
||||
foreach ($matches as $match) {
|
||||
$number = (float) str_replace(',', '', $match[1]);
|
||||
|
||||
// If there's a 'k' suffix, multiply by 1000
|
||||
if (!empty($match[2]) && strtolower($match[2]) === 'k') {
|
||||
$number *= 1000;
|
||||
}
|
||||
|
||||
// If it's hourly, convert to annual
|
||||
if ($isHourly) {
|
||||
$number *= 2080; // 40 hours/week * 52 weeks
|
||||
}
|
||||
|
||||
$numbers[] = $number;
|
||||
}
|
||||
|
||||
if (count($numbers) >= 2) {
|
||||
return $type === 'min' ? min($numbers) : max($numbers);
|
||||
|
||||
Reference in New Issue
Block a user