Skip to content

Commit

Permalink
Merge branch 'main' into 11593-larastan-call-to-function-always
Browse files Browse the repository at this point in the history
  • Loading branch information
vd1992 authored Sep 27, 2024
2 parents da0eb95 + 271196f commit 011cfc7
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 17 deletions.
2 changes: 1 addition & 1 deletion api/app/Enums/GenericJobTitleKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ enum GenericJobTitleKey
case TECHNICAL_ADVISOR_IT03;
case SENIOR_ADVISOR_IT04;
case MANAGER_IT04;
case EXECUTIVE_EX03;
case DIGITAL_LEADER_EX_03;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
DB::table('generic_job_titles')
->where('key', 'EXECUTIVE_EX03')
->update(['key' => 'DIGITAL_LEADER_EX_03']);
}

/**
* Reverse the migrations.
*/
public function down(): void
{
DB::table('generic_job_titles')
->where('key', 'DIGITAL_LEADER_EX_03')
->update(['key' => 'EXECUTIVE_EX03']);
}
};
2 changes: 1 addition & 1 deletion api/database/seeders/GenericJobTitleSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function run()

],
[
'key' => GenericJobTitleKey::EXECUTIVE_EX03->name,
'key' => GenericJobTitleKey::DIGITAL_LEADER_EX_03->name,
'name' => [
'en' => 'Digital Leaders',
'fr' => 'Chefs de file du numérique',
Expand Down
93 changes: 79 additions & 14 deletions api/database/seeders/PoolCandidateTestSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

use App\Enums\ApplicationStep;
use App\Enums\ArmedForcesStatus;
use App\Enums\CandidateRemovalReason;
use App\Enums\CitizenshipStatus;
use App\Enums\ClaimVerificationResult;
use App\Enums\PoolCandidateStatus;
use App\Models\Department;
use App\Models\Pool;
use App\Models\PoolCandidate;
use App\Models\User;
Expand Down Expand Up @@ -40,7 +43,14 @@ public function run()
->asApplicant()
->withSkillsAndExperiences()
->afterCreating(function (User $user) {
$this->applyToAllPools($user, PoolCandidateStatus::QUALIFIED_AVAILABLE, now()->addYears(2));
$this->applyToAllPools(
user: $user,
status: PoolCandidateStatus::PLACED_INDETERMINATE->name,
expiryDate: now()->addYears(2),
priorityStatus: ClaimVerificationResult::ACCEPTED->name,
priorityExpiry: now()->addYears(2),
placedAt: now()->subDays(2),
);
})
->create([
'first_name' => 'Perfect',
Expand All @@ -57,7 +67,12 @@ public function run()
->asApplicant()
->withSkillsAndExperiences()
->afterCreating(function (User $user) {
$this->applyToAllPools($user, PoolCandidateStatus::QUALIFIED_AVAILABLE, now()->addYears(2));
$this->applyToAllPools(
user: $user,
status: PoolCandidateStatus::QUALIFIED_AVAILABLE->name,
expiryDate: now()->addYears(2),
veteranStatus: ClaimVerificationResult::UNVERIFIED->name,
);
})
->create([
'first_name' => 'Entry-level',
Expand All @@ -73,23 +88,33 @@ public function run()
->asApplicant()
->withSkillsAndExperiences()
->afterCreating(function (User $user) {
$this->applyToAllPools($user, PoolCandidateStatus::PLACED_TENTATIVE, now()->addYears(2));
$this->applyToAllPools(
user: $user,
status: PoolCandidateStatus::PLACED_TENTATIVE->name,
expiryDate: now()->addYears(2),
veteranStatus: ClaimVerificationResult::REJECTED->name,
);
})
->create([
'first_name' => 'Assertive',
'last_name' => 'Non-veteran',
'email' => '[email protected]',
'sub' => '[email protected]',
'citizenship' => CitizenshipStatus::PERMANENT_RESIDENT->name,
'armed_forces_status' => ArmedForcesStatus::NON_CAF->name,
'armed_forces_status' => ArmedForcesStatus::VETERAN->name,
]);

// 4 - Absent Canadian
User::factory()
->asApplicant()
->withSkillsAndExperiences()
->afterCreating(function (User $user) {
$this->applyToAllPools($user, PoolCandidateStatus::REMOVED);
$this->applyToAllPools(
user: $user,
status: PoolCandidateStatus::REMOVED->name,
removalReason: CandidateRemovalReason::NOT_RESPONSIVE->name,
expiryDate: now()->addYears(2),
);
})
->create([
'first_name' => 'Absent',
Expand All @@ -104,7 +129,11 @@ public function run()
->asApplicant()
->withSkillsAndExperiences()
->afterCreating(function (User $user) {
$this->applyToAllPools($user, PoolCandidateStatus::QUALIFIED_AVAILABLE, now()->addYears(2));
$this->applyToAllPools(
user: $user,
status: PoolCandidateStatus::SCREENED_OUT_APPLICATION->name,
expiryDate: now()->addYears(2),
);
})
->create([
'first_name' => 'Screened-out',
Expand All @@ -119,7 +148,12 @@ public function run()
->asApplicant()
->withSkillsAndExperiences()
->afterCreating(function (User $user) {
$this->applyToAllPools($user, PoolCandidateStatus::QUALIFIED_AVAILABLE, now()->addYears(2));
$this->applyToAllPools(
user: $user,
status: PoolCandidateStatus::REMOVED->name,
removalReason: CandidateRemovalReason::OTHER->name,
expiryDate: now()->addYears(2),
);
})
->create([
'first_name' => 'Failed',
Expand All @@ -134,7 +168,11 @@ public function run()
->asApplicant()
->withSkillsAndExperiences()
->afterCreating(function (User $user) {
$this->applyToAllPools($user, PoolCandidateStatus::QUALIFIED_AVAILABLE, now()->addYears(2));
$this->applyToAllPools(
user: $user,
status: PoolCandidateStatus::QUALIFIED_AVAILABLE->name,
expiryDate: now()->addYears(2),
);
})
->create([
'first_name' => 'Entry-level',
Expand All @@ -149,7 +187,12 @@ public function run()
->asApplicant()
->withSkillsAndExperiences()
->afterCreating(function (User $user) {
$this->applyToAllPools($user, PoolCandidateStatus::SCREENED_OUT_ASSESSMENT);
$this->applyToAllPools(
user: $user,
status: PoolCandidateStatus::SCREENED_OUT_ASSESSMENT->name,
priorityStatus: ClaimVerificationResult::UNVERIFIED->name,
expiryDate: now()->addYears(2),
);
})
->create([
'first_name' => 'Unsuccessful',
Expand All @@ -158,25 +201,47 @@ public function run()
'sub' => '[email protected]',
'citizenship' => CitizenshipStatus::CITIZEN->name,
]);

}

private function applyToAllPools($user, $status, $expiryDate = null, $placedDepartmentId = null)
private function applyToAllPools(
$user,
$status,
$removalReason = null,
$expiryDate = null,
$priorityStatus = null,
$priorityExpiry = null,
$veteranStatus = null,
$veteranExpiry = null,
$placedAt = null)
{
foreach ($this->publishedPools as $pool) {
// create a pool candidate in the pool
PoolCandidate::factory()->for($user)->for($pool)
->afterCreating(function (PoolCandidate $candidate) {
->afterCreating(function (PoolCandidate $candidate) use ($removalReason, $placedAt, $priorityStatus, $priorityExpiry, $veteranStatus, $veteranExpiry) {
if ($removalReason == CandidateRemovalReason::OTHER->name) {
$candidate->removal_reason_other = 'Other reason';
} else {
$candidate->removal_reason_other = null;
}
$candidate->priority_verification = $priorityStatus;
$candidate->priority_verification_expiry = $priorityExpiry;
$candidate->veteran_verification = $veteranStatus;
$candidate->veteran_verification_expiry = $veteranExpiry;
$candidate->placed_department_id = isset($placedAt) ?
Department::inRandomOrder()->first()->id : null;

$candidate->save();
$candidate->setApplicationSnapshot();
})
->create([
'pool_id' => $pool->id,
'user_id' => $user->id,
'submitted_at' => config('constants.far_past_date'),
'submitted_steps' => array_column(ApplicationStep::cases(), 'name'),
'pool_candidate_status' => $status->name,
'pool_candidate_status' => $status,
'removal_reason' => $removalReason,
'expiry_date' => $expiryDate,
'placed_department_id' => $placedDepartmentId,
'placed_at' => $placedAt,
]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion api/storage/app/lighthouse-schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2846,7 +2846,7 @@ enum GenericJobTitleKey {
TECHNICAL_ADVISOR_IT03
SENIOR_ADVISOR_IT04
MANAGER_IT04
EXECUTIVE_EX03
DIGITAL_LEADER_EX_03
}

enum GovEmployeeType {
Expand Down

0 comments on commit 011cfc7

Please sign in to comment.