-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 12164-candidate-status-chips
- Loading branch information
Showing
171 changed files
with
5,579 additions
and
2,084 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace App\Casts; | ||
|
||
use Illuminate\Contracts\Database\Eloquent\CastsAttributes; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Support\Facades\App; | ||
|
||
class LocalizedString implements CastsAttributes | ||
{ | ||
/** | ||
* Cast the given value. | ||
* | ||
* @param array<string, mixed> $attributes | ||
*/ | ||
public function get(Model $model, string $key, mixed $value, array $attributes): mixed | ||
{ | ||
if (is_null($value) || $value === '' || $value === 'null') { | ||
return null; | ||
} | ||
|
||
$decodedValue = is_array($value) ? $value : json_decode($value, true); | ||
$locale = App::getLocale() ?? 'en'; | ||
|
||
return [ | ||
...$decodedValue, | ||
'localized' => $decodedValue[$locale] ?? null, | ||
]; | ||
} | ||
|
||
/** | ||
* Prepare the given value for storage. | ||
* | ||
* @param array<string, mixed> $attributes | ||
*/ | ||
public function set(Model $model, string $key, mixed $value, array $attributes): mixed | ||
{ | ||
return json_encode($value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\ApplicantFilter; | ||
use App\Models\JobPosterTemplate; | ||
use App\Models\Pool; | ||
use App\Models\WorkStream; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Collection; | ||
|
||
/** | ||
* Temporary command to support migration of | ||
* PoolStream enum to WorkStream model. | ||
* | ||
* NOTE: Should be ran at any point during deployment. | ||
* The rest of the code does not explicitly depend on this | ||
* command but it should not be left since the frontend will | ||
* display empty values until this has been ran. | ||
* | ||
* TODO: Remove in #12142 | ||
*/ | ||
class MigratePoolStream extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'app:migrate-pool-stream'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Migrates the pool stream enum to work stream model'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle() | ||
{ | ||
|
||
$workStreams = WorkStream::all(); | ||
|
||
$this->info('Updating job poster template work streams...'); | ||
$jobPosterTemplatesUpdated = 0; | ||
JobPosterTemplate::whereNotNull('stream')->chunkById(200, function (Collection $jobPosterTemplates) use ($workStreams, &$jobPosterTemplatesUpdated) { | ||
foreach ($jobPosterTemplates as $jobPosterTemplate) { | ||
$stream = $workStreams->where('key', $jobPosterTemplate->stream)->first(); | ||
if ($stream) { | ||
$jobPosterTemplate->work_stream_id = $stream->id; | ||
$jobPosterTemplate->save(); | ||
$jobPosterTemplatesUpdated++; | ||
} else { | ||
$this->error(sprintf('Work stream (%s) not found for job poster template (%s)', | ||
$jobPosterTemplate->stream, | ||
$jobPosterTemplate->id)); | ||
} | ||
} | ||
}); | ||
$this->info("Updated $jobPosterTemplatesUpdated job poster templates"); | ||
|
||
$this->newLine(); | ||
$this->info('Updating pool work streams...'); | ||
$poolsUpdated = 0; | ||
Pool::whereNotNull('stream')->chunkById(200, function (Collection $pools) use ($workStreams, &$poolsUpdated) { | ||
foreach ($pools as $pool) { | ||
$stream = $workStreams->where('key', $pool->stream)->first(); | ||
if ($stream) { | ||
$pool->work_stream_id = $stream->id; | ||
$pool->save(); | ||
$poolsUpdated++; | ||
} else { | ||
$this->error(sprintf('Work stream (%s) not found for pool (%s)', | ||
$pool->stream, | ||
$pool->id)); | ||
} | ||
} | ||
}); | ||
$this->info("Updated $poolsUpdated pools"); | ||
|
||
$applicantFiltersUpdated = 0; | ||
$this->newLine(); | ||
$this->info('Updated applicant filter work streams...'); | ||
ApplicantFilter::whereNotNull('qualified_streams')->chunkById(200, function (Collection $applicantFilters) use ($workStreams, &$applicantFiltersUpdated) { | ||
foreach ($applicantFilters as $applicantFilter) { | ||
$streams = $workStreams->whereIn('key', $applicantFilter->qualified_streams)->pluck('id'); | ||
if ($streams->count()) { | ||
$applicantFilter->workStreams()->sync($streams); | ||
$applicantFiltersUpdated++; | ||
} else { | ||
$this->error(sprintf('Work streams (%s) not found for applicant filter (%s)', | ||
implode(', ', $applicantFilter->qualified_streams), | ||
$applicantFilter->id)); | ||
} | ||
} | ||
}); | ||
$this->info("Updated $applicantFiltersUpdated applicant filters"); | ||
|
||
$this->newLine(); | ||
$this->info('Migration completed'); | ||
$this->table(['Model', 'Affected'], [ | ||
['JobPosterTemplate', $jobPosterTemplatesUpdated], | ||
['Pool', $poolsUpdated], | ||
['ApplicantFilter', $applicantFiltersUpdated], | ||
]); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Enums\PoolCandidateStatus; | ||
use App\Models\PoolCandidate; | ||
use Carbon\Carbon; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Database\Eloquent\Collection; | ||
|
||
class SuspendPlacedCandidates extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'app:suspend-placed-candidates'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Set suspended at date to now() for placed term and indeterminate candidates'; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return int | ||
*/ | ||
public function handle() | ||
{ | ||
$applicableStatuses = [PoolCandidateStatus::PLACED_TERM->name, PoolCandidateStatus::PLACED_INDETERMINATE->name]; | ||
|
||
PoolCandidate::whereIn('pool_candidate_status', $applicableStatuses) | ||
->whereNull('suspended_at') | ||
->with('user') | ||
->chunkById(100, function (Collection $candidates) { | ||
foreach ($candidates as $candidate) { | ||
/** @var \App\Models\PoolCandidate $candidate */ | ||
$candidate->suspended_at = Carbon::now(); | ||
$candidate->save(); | ||
} | ||
} | ||
); | ||
|
||
return Command::SUCCESS; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.