From 5f325e8d0747778f85eda559c6ae260d4a780d52 Mon Sep 17 00:00:00 2001 From: vd1992 <40485260+vd1992@users.noreply.github.com> Date: Tue, 17 Dec 2024 10:22:44 -0700 Subject: [PATCH 01/10] create artisan command --- .../Commands/SuspendPlacedCandidates.php | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 api/app/Console/Commands/SuspendPlacedCandidates.php diff --git a/api/app/Console/Commands/SuspendPlacedCandidates.php b/api/app/Console/Commands/SuspendPlacedCandidates.php new file mode 100644 index 00000000000..603064b86da --- /dev/null +++ b/api/app/Console/Commands/SuspendPlacedCandidates.php @@ -0,0 +1,50 @@ +name, PoolCandidateStatus::PLACED_INDETERMINATE->name]; + + DB::beginTransaction(); + try { + DB::table('pool_candidates') + ->whereIn('pool_candidate_status', $applicableStatuses) + ->whereNull('suspended_at') + ->update(['suspended_at' => $dateNow]); + DB::commit(); + } catch (\Throwable $error) { + DB::rollBack(); + throw $error; + } + + return Command::SUCCESS; + } +} From 426e36d0f0b1a167a2a6d71f1caeaf0df2d07236 Mon Sep 17 00:00:00 2001 From: vd1992 <40485260+vd1992@users.noreply.github.com> Date: Tue, 17 Dec 2024 10:45:59 -0700 Subject: [PATCH 02/10] update placement mutations --- api/app/GraphQL/Mutations/PlaceCandidate.php | 7 +++++++ api/app/GraphQL/Mutations/RevertPlaceCandidate.php | 1 + 2 files changed, 8 insertions(+) diff --git a/api/app/GraphQL/Mutations/PlaceCandidate.php b/api/app/GraphQL/Mutations/PlaceCandidate.php index f5b3e62b769..8927fdce146 100644 --- a/api/app/GraphQL/Mutations/PlaceCandidate.php +++ b/api/app/GraphQL/Mutations/PlaceCandidate.php @@ -2,6 +2,7 @@ namespace App\GraphQL\Mutations; +use App\Enums\PlacementType; use App\Models\PoolCandidate; use Carbon\Carbon; @@ -25,6 +26,12 @@ public function __invoke($_, array $args) $candidate->computed_final_decision = $finalDecision['decision']; $candidate->computed_final_decision_weight = $finalDecision['weight']; + if ($placementType === PlacementType::PLACED_TERM->name || $placementType === PlacementType::PLACED_INDETERMINATE->name) { + $candidate->suspended_at = $now; + } else { + $candidate->suspended_at = null; + } + $candidate->save(); return $candidate; diff --git a/api/app/GraphQL/Mutations/RevertPlaceCandidate.php b/api/app/GraphQL/Mutations/RevertPlaceCandidate.php index 9adfc1042ce..7dd869d14b7 100644 --- a/api/app/GraphQL/Mutations/RevertPlaceCandidate.php +++ b/api/app/GraphQL/Mutations/RevertPlaceCandidate.php @@ -17,6 +17,7 @@ public function __invoke($_, array $args) $candidate->pool_candidate_status = PoolCandidateStatus::QUALIFIED_AVAILABLE->name; $candidate->placed_at = null; $candidate->placed_department_id = null; + $candidate->suspended_at = null; $candidate->save(); From eba0ffca2600b7176391680a71a8341eae80aa97 Mon Sep 17 00:00:00 2001 From: vd1992 <40485260+vd1992@users.noreply.github.com> Date: Tue, 17 Dec 2024 10:46:20 -0700 Subject: [PATCH 03/10] update qualifiedEquivalent --- api/app/Enums/PoolCandidateStatus.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/app/Enums/PoolCandidateStatus.php b/api/app/Enums/PoolCandidateStatus.php index 3140cfb378a..85e77b78761 100644 --- a/api/app/Enums/PoolCandidateStatus.php +++ b/api/app/Enums/PoolCandidateStatus.php @@ -28,12 +28,15 @@ enum PoolCandidateStatus case EXPIRED; case REMOVED; + // searchable candidates, so the available status and others treated as available for search purposes public static function qualifiedEquivalentGroup(): array { return [ PoolCandidateStatus::QUALIFIED_AVAILABLE->name, PoolCandidateStatus::PLACED_TENTATIVE->name, PoolCandidateStatus::PLACED_CASUAL->name, + PoolCandidateStatus::PLACED_TERM->name, + PoolCandidateStatus::PLACED_INDETERMINATE->name, ]; } From 7322aa1c67d37ff572f96dd209d85ef311cd9f8e Mon Sep 17 00:00:00 2001 From: vd1992 <40485260+vd1992@users.noreply.github.com> Date: Tue, 17 Dec 2024 12:15:21 -0700 Subject: [PATCH 04/10] test mutations --- api/tests/Feature/PoolCandidateUpdateTest.php | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/api/tests/Feature/PoolCandidateUpdateTest.php b/api/tests/Feature/PoolCandidateUpdateTest.php index 770bf98d916..efd557d10ca 100644 --- a/api/tests/Feature/PoolCandidateUpdateTest.php +++ b/api/tests/Feature/PoolCandidateUpdateTest.php @@ -160,6 +160,7 @@ protected function setUp(): void placedDepartment { id } + suspendedAt } } '; @@ -175,6 +176,7 @@ protected function setUp(): void placedDepartment { id } + suspendedAt } } '; @@ -502,12 +504,66 @@ public function testPlaceCandidateMutation(): void assertSame($response['placedDepartment']['id'], $department->id); } + // placing candidates sets suspended_at automatically or keeps/makes it null appropriately + public function testPlaceCandidateMutationSuspensionLogic(): void + { + $department = Department::factory()->create(); + $this->poolCandidate->pool_candidate_status = PoolCandidateStatus::QUALIFIED_AVAILABLE->name; + $this->poolCandidate->placed_at = null; + $this->poolCandidate->save(); + $placedDoNotSuspend = [ + PlacementType::PLACED_TENTATIVE->name, + PlacementType::PLACED_CASUAL->name, + ]; + $placedDoSuspend = [ + PlacementType::PLACED_TERM->name, + PlacementType::PLACED_INDETERMINATE->name, + ]; + + foreach ($placedDoNotSuspend as $value) { + $response = $this->actingAs($this->poolOperatorUser, 'api') + ->graphQL( + $this->placeCandidateMutation, + [ + 'id' => $this->poolCandidate->id, + 'placeCandidate' => [ + 'placementType' => $value, + 'departmentId' => $department->id, + ], + ] + )->json('data.placeCandidate'); + + assertSame($response['status']['value'], $value); + assertNotNull($response['placedAt']); + assertNull($response['suspendedAt']); + } + + foreach ($placedDoSuspend as $value) { + $response = $this->actingAs($this->poolOperatorUser, 'api') + ->graphQL( + $this->placeCandidateMutation, + [ + 'id' => $this->poolCandidate->id, + 'placeCandidate' => [ + 'placementType' => $value, + 'departmentId' => $department->id, + ], + ] + )->json('data.placeCandidate'); + + assertSame($response['status']['value'], $value); + assertNotNull($response['placedAt']); + assertNotNull($response['suspendedAt']); + } + } + public function testRevertPlaceCandidateMutation(): void { $department = Department::factory()->create(); $this->poolCandidate->pool_candidate_status = PoolCandidateStatus::NEW_APPLICATION->name; $this->poolCandidate->placed_department_id = $department->id; $this->poolCandidate->placed_at = config('constants.far_past_date'); + $this->poolCandidate->suspended_at = config('constants.far_past_date'); $this->poolCandidate->save(); // cannot execute mutation due to candidate not being placed @@ -535,6 +591,7 @@ public function testRevertPlaceCandidateMutation(): void assertSame($response['status']['value'], PoolCandidateStatus::QUALIFIED_AVAILABLE->name); assertNull($response['placedAt']); assertNull($response['placedDepartment']); + assertNull($response['suspendedAt']); } public function testQualifyCandidateMutation(): void From 092fd92e4bb322e4562ae98292a9c8c8aa8528d0 Mon Sep 17 00:00:00 2001 From: vd1992 <40485260+vd1992@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:04:05 -0700 Subject: [PATCH 05/10] search testing --- .../Queries/CountPoolCandidatesByPool.php | 2 +- .../Feature/CountPoolCandidatesByPoolTest.php | 56 +++++++++++++++++++ api/tests/Feature/PoolCandidateTest.php | 36 ++++++++++++ 3 files changed, 93 insertions(+), 1 deletion(-) diff --git a/api/app/GraphQL/Queries/CountPoolCandidatesByPool.php b/api/app/GraphQL/Queries/CountPoolCandidatesByPool.php index f5a002d8fc7..cc5c65bbd72 100644 --- a/api/app/GraphQL/Queries/CountPoolCandidatesByPool.php +++ b/api/app/GraphQL/Queries/CountPoolCandidatesByPool.php @@ -33,7 +33,7 @@ public function __invoke($_, array $args) } }); - // available candidates scope (scope CANDIDATE_STATUS_QUALIFIED_AVAILABLE or CANDIDATE_STATUS_PLACED_CASUAL, or PLACED_TENTATIVE) + // available candidates scope (qualifiedEquivalentGroup, not expired, not suspended) PoolCandidate::scopeAvailable($queryBuilder); // Only display IT & OTHER publishing group candidates diff --git a/api/tests/Feature/CountPoolCandidatesByPoolTest.php b/api/tests/Feature/CountPoolCandidatesByPoolTest.php index d0ba1da5c5c..aa955614ae2 100644 --- a/api/tests/Feature/CountPoolCandidatesByPoolTest.php +++ b/api/tests/Feature/CountPoolCandidatesByPoolTest.php @@ -828,4 +828,60 @@ public function testAdditionalAvailabilityScopes() ], ]); } + + // asserts placed term/indeterminate candidates can appear in this query, can't check by id though so check that 2 out of 3 appear + public function testPlacedSuspendedNotSuspendedCandidates() + { + $itPool = Pool::factory()->create([ + ...$this->poolData(), + 'publishing_group' => PublishingGroup::IT_JOBS->name, + ]); + PoolCandidate::truncate(); + $candidate = PoolCandidate::factory()->availableInSearch()->create([ + 'pool_id' => $itPool, + 'pool_candidate_status' => PoolCandidateStatus::PLACED_TERM->name, + ]); + $candidate->suspended_at = null; + $candidate->save(); + $candidate = PoolCandidate::factory()->availableInSearch()->create([ + 'pool_id' => $itPool, + 'pool_candidate_status' => PoolCandidateStatus::PLACED_INDETERMINATE->name, + ]); + $candidate->suspended_at = null; + $candidate->save(); + $suspendedCandidate = PoolCandidate::factory()->availableInSearch()->create([ + 'pool_id' => $itPool, + 'pool_candidate_status' => PoolCandidateStatus::PLACED_TERM->name, + ]); + $suspendedCandidate->suspended_at = config('constants.far_past_datetime'); + $suspendedCandidate->save(); + + $this->graphQL( + /** @lang GraphQL */ + ' + query ($where: ApplicantFilterInput) { + countPoolCandidatesByPool(where: $where) { + pool { id } + candidateCount + } + } + ', + [ + 'where' => [ + 'pools' => [ + ['id' => $itPool->id], + ], + ], + ] + )->assertSimilarJson([ + 'data' => [ + 'countPoolCandidatesByPool' => [ + [ + 'pool' => ['id' => $itPool->id], + 'candidateCount' => 2, + ], + ], + ], + ]); + } } diff --git a/api/tests/Feature/PoolCandidateTest.php b/api/tests/Feature/PoolCandidateTest.php index 2451366fe7f..634b1d84651 100644 --- a/api/tests/Feature/PoolCandidateTest.php +++ b/api/tests/Feature/PoolCandidateTest.php @@ -20,6 +20,8 @@ use Tests\TestCase; use Tests\UsesProtectedGraphqlEndpoint; +use function PHPUnit\Framework\assertEqualsCanonicalizing; + class PoolCandidateTest extends TestCase { use MakesGraphQLRequests; @@ -849,4 +851,38 @@ public function testScopeCandidatesInCommunity(): void ])->assertJsonFragment(['total' => 1]) ->assertJsonFragment(['id' => $communityCandidate->id]); } + + // test scopeAvailable + public function testScopeAvailable(): void + { + PoolCandidate::truncate(); + $candidate = PoolCandidate::factory()->availableInSearch()->create([ + 'pool_candidate_status' => PoolCandidateStatus::PLACED_TERM->name, + ]); + $candidate->expiry_date = null; + $candidate->suspended_at = null; + $candidate->save(); + + $suspendedCandidate = PoolCandidate::factory()->availableInSearch()->create([ + 'pool_candidate_status' => PoolCandidateStatus::PLACED_TERM->name, + ]); + $suspendedCandidate->expiry_date = null; + $suspendedCandidate->suspended_at = config('constants.far_past_datetime'); + $suspendedCandidate->save(); + + $expiredCandidate = PoolCandidate::factory()->availableInSearch()->create([ + 'pool_candidate_status' => PoolCandidateStatus::PLACED_TERM->name, + ]); + $expiredCandidate->expiry_date = config('constants.past_date'); + $expiredCandidate->suspended_at = null; + $expiredCandidate->save(); + + $queryBuilder = PoolCandidate::query(); + $candidateIds = PoolCandidate::scopeAvailable($queryBuilder)->get()->pluck('id')->toArray(); + + // suspended and expired not present + assertEqualsCanonicalizing([ + $candidate->id, + ], $candidateIds); + } } From eb056cae38dbab6f1f7b10863ff391392c9342cd Mon Sep 17 00:00:00 2001 From: vd1992 <40485260+vd1992@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:30:38 -0700 Subject: [PATCH 06/10] fix test --- api/tests/Feature/UserTest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api/tests/Feature/UserTest.php b/api/tests/Feature/UserTest.php index fe8c3148f3b..257eaf242fc 100644 --- a/api/tests/Feature/UserTest.php +++ b/api/tests/Feature/UserTest.php @@ -1771,11 +1771,12 @@ public function testCountApplicantsQuery(): void 'looking_for_bilingual' => false, ]), ]); - // Already placed - should not appear in searches + // Already placed - should appear in searches PoolCandidate::factory()->create([ 'pool_id' => $pool1['id'], 'expiry_date' => config('constants.far_future_date'), 'pool_candidate_status' => PoolCandidateStatus::PLACED_TERM->name, + 'suspended_at' => null, 'user_id' => User::factory([ 'looking_for_english' => true, 'looking_for_french' => false, @@ -1812,7 +1813,7 @@ public function testCountApplicantsQuery(): void ); $response->assertJson([ 'data' => [ - 'countApplicants' => 14, // including base admin user + 'countApplicants' => 15, // including base admin user ], ]); @@ -1834,7 +1835,7 @@ public function testCountApplicantsQuery(): void ] )->assertJson([ 'data' => [ - 'countApplicants' => 9, //including base admin user + 'countApplicants' => 10, //including base admin user ], ]); } From 70840c18e9662851d0ae0b09cdf41ea87f0c7d2c Mon Sep 17 00:00:00 2001 From: vd1992 <40485260+vd1992@users.noreply.github.com> Date: Wed, 18 Dec 2024 11:48:21 -0700 Subject: [PATCH 07/10] switch to Eloquent --- .../Commands/SuspendPlacedCandidates.php | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/api/app/Console/Commands/SuspendPlacedCandidates.php b/api/app/Console/Commands/SuspendPlacedCandidates.php index 603064b86da..a72a5a65078 100644 --- a/api/app/Console/Commands/SuspendPlacedCandidates.php +++ b/api/app/Console/Commands/SuspendPlacedCandidates.php @@ -3,9 +3,10 @@ namespace App\Console\Commands; use App\Enums\PoolCandidateStatus; +use App\Models\PoolCandidate; use Carbon\Carbon; use Illuminate\Console\Command; -use Illuminate\Support\Facades\DB; +use Illuminate\Database\Eloquent\Collection; class SuspendPlacedCandidates extends Command { @@ -30,20 +31,18 @@ class SuspendPlacedCandidates extends Command */ public function handle() { - $dateNow = Carbon::now(); $applicableStatuses = [PoolCandidateStatus::PLACED_TERM->name, PoolCandidateStatus::PLACED_INDETERMINATE->name]; - DB::beginTransaction(); - try { - DB::table('pool_candidates') - ->whereIn('pool_candidate_status', $applicableStatuses) - ->whereNull('suspended_at') - ->update(['suspended_at' => $dateNow]); - DB::commit(); - } catch (\Throwable $error) { - DB::rollBack(); - throw $error; - } + PoolCandidate::whereIn('pool_candidate_status', $applicableStatuses) + ->whereNull('suspended_at') + ->with('user') + ->chunkById(100, function (Collection $candidates) { + foreach ($candidates as $candidate) { + $candidate->suspended_at = Carbon::now(); + $candidate->save(); + } + } + ); return Command::SUCCESS; } From 46ff561c360543acb0c76fc4cbe1b22bd710d28f Mon Sep 17 00:00:00 2001 From: vd1992 <40485260+vd1992@users.noreply.github.com> Date: Wed, 18 Dec 2024 11:49:44 -0700 Subject: [PATCH 08/10] add comment --- api/app/GraphQL/Mutations/PlaceCandidate.php | 1 + 1 file changed, 1 insertion(+) diff --git a/api/app/GraphQL/Mutations/PlaceCandidate.php b/api/app/GraphQL/Mutations/PlaceCandidate.php index 8927fdce146..f7797d260de 100644 --- a/api/app/GraphQL/Mutations/PlaceCandidate.php +++ b/api/app/GraphQL/Mutations/PlaceCandidate.php @@ -26,6 +26,7 @@ public function __invoke($_, array $args) $candidate->computed_final_decision = $finalDecision['decision']; $candidate->computed_final_decision_weight = $finalDecision['weight']; + // If setting to term or indeterminate automatically suspend the candidate, otherwise null the field if ($placementType === PlacementType::PLACED_TERM->name || $placementType === PlacementType::PLACED_INDETERMINATE->name) { $candidate->suspended_at = $now; } else { From 9af9134ea554e83f7db886038b86be858c05f194 Mon Sep 17 00:00:00 2001 From: vd1992 <40485260+vd1992@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:50:37 -0700 Subject: [PATCH 09/10] tests feedback --- .../Feature/CountPoolCandidatesByPoolTest.php | 16 +++++++--------- api/tests/Feature/PoolCandidateTest.php | 15 ++++++--------- api/tests/Feature/PoolCandidateUpdateTest.php | 12 ++++++------ api/tests/Feature/UserTest.php | 10 +++++++++- 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/api/tests/Feature/CountPoolCandidatesByPoolTest.php b/api/tests/Feature/CountPoolCandidatesByPoolTest.php index aa955614ae2..fdd72b71507 100644 --- a/api/tests/Feature/CountPoolCandidatesByPoolTest.php +++ b/api/tests/Feature/CountPoolCandidatesByPoolTest.php @@ -837,25 +837,23 @@ public function testPlacedSuspendedNotSuspendedCandidates() 'publishing_group' => PublishingGroup::IT_JOBS->name, ]); PoolCandidate::truncate(); - $candidate = PoolCandidate::factory()->availableInSearch()->create([ + PoolCandidate::factory()->availableInSearch()->create([ 'pool_id' => $itPool, 'pool_candidate_status' => PoolCandidateStatus::PLACED_TERM->name, + 'suspended_at' => null, ]); - $candidate->suspended_at = null; - $candidate->save(); - $candidate = PoolCandidate::factory()->availableInSearch()->create([ + PoolCandidate::factory()->availableInSearch()->create([ 'pool_id' => $itPool, 'pool_candidate_status' => PoolCandidateStatus::PLACED_INDETERMINATE->name, + 'suspended_at' => null, ]); - $candidate->suspended_at = null; - $candidate->save(); - $suspendedCandidate = PoolCandidate::factory()->availableInSearch()->create([ + PoolCandidate::factory()->availableInSearch()->create([ 'pool_id' => $itPool, 'pool_candidate_status' => PoolCandidateStatus::PLACED_TERM->name, + 'suspended_at' => config('constants.far_past_datetime'), ]); - $suspendedCandidate->suspended_at = config('constants.far_past_datetime'); - $suspendedCandidate->save(); + // expect 2, the 2 un-suspended ones $this->graphQL( /** @lang GraphQL */ ' diff --git a/api/tests/Feature/PoolCandidateTest.php b/api/tests/Feature/PoolCandidateTest.php index 634b1d84651..19ef7397176 100644 --- a/api/tests/Feature/PoolCandidateTest.php +++ b/api/tests/Feature/PoolCandidateTest.php @@ -858,24 +858,21 @@ public function testScopeAvailable(): void PoolCandidate::truncate(); $candidate = PoolCandidate::factory()->availableInSearch()->create([ 'pool_candidate_status' => PoolCandidateStatus::PLACED_TERM->name, + 'expiry_date' => null, + 'suspended_at' => null, ]); - $candidate->expiry_date = null; - $candidate->suspended_at = null; - $candidate->save(); $suspendedCandidate = PoolCandidate::factory()->availableInSearch()->create([ 'pool_candidate_status' => PoolCandidateStatus::PLACED_TERM->name, + 'expiry_date' => null, + 'suspended_at' => config('constants.far_past_datetime'), ]); - $suspendedCandidate->expiry_date = null; - $suspendedCandidate->suspended_at = config('constants.far_past_datetime'); - $suspendedCandidate->save(); $expiredCandidate = PoolCandidate::factory()->availableInSearch()->create([ 'pool_candidate_status' => PoolCandidateStatus::PLACED_TERM->name, + 'expiry_date' => config('constants.past_date'), + 'suspended_at' => null, ]); - $expiredCandidate->expiry_date = config('constants.past_date'); - $expiredCandidate->suspended_at = null; - $expiredCandidate->save(); $queryBuilder = PoolCandidate::query(); $candidateIds = PoolCandidate::scopeAvailable($queryBuilder)->get()->pluck('id')->toArray(); diff --git a/api/tests/Feature/PoolCandidateUpdateTest.php b/api/tests/Feature/PoolCandidateUpdateTest.php index efd557d10ca..34735e8e7c9 100644 --- a/api/tests/Feature/PoolCandidateUpdateTest.php +++ b/api/tests/Feature/PoolCandidateUpdateTest.php @@ -520,38 +520,38 @@ public function testPlaceCandidateMutationSuspensionLogic(): void PlacementType::PLACED_INDETERMINATE->name, ]; - foreach ($placedDoNotSuspend as $value) { + foreach ($placedDoNotSuspend as $placementType) { $response = $this->actingAs($this->poolOperatorUser, 'api') ->graphQL( $this->placeCandidateMutation, [ 'id' => $this->poolCandidate->id, 'placeCandidate' => [ - 'placementType' => $value, + 'placementType' => $placementType, 'departmentId' => $department->id, ], ] )->json('data.placeCandidate'); - assertSame($response['status']['value'], $value); + assertSame($response['status']['value'], $placementType); assertNotNull($response['placedAt']); assertNull($response['suspendedAt']); } - foreach ($placedDoSuspend as $value) { + foreach ($placedDoSuspend as $placementType) { $response = $this->actingAs($this->poolOperatorUser, 'api') ->graphQL( $this->placeCandidateMutation, [ 'id' => $this->poolCandidate->id, 'placeCandidate' => [ - 'placementType' => $value, + 'placementType' => $placementType, 'departmentId' => $department->id, ], ] )->json('data.placeCandidate'); - assertSame($response['status']['value'], $value); + assertSame($response['status']['value'], $placementType); assertNotNull($response['placedAt']); assertNotNull($response['suspendedAt']); } diff --git a/api/tests/Feature/UserTest.php b/api/tests/Feature/UserTest.php index 257eaf242fc..4363eea456b 100644 --- a/api/tests/Feature/UserTest.php +++ b/api/tests/Feature/UserTest.php @@ -1729,6 +1729,7 @@ public function testCountApplicantsQuery(): void 'user_id' => $user['id'], ]); + // group one PoolCandidate::factory()->count(8)->create([ 'pool_id' => $pool1['id'], 'expiry_date' => config('constants.far_future_date'), @@ -1739,6 +1740,7 @@ public function testCountApplicantsQuery(): void 'looking_for_bilingual' => false, ]), ]); + // group two PoolCandidate::factory()->count(5)->create([ 'pool_id' => $pool1['id'], 'expiry_date' => config('constants.far_future_date'), @@ -1750,6 +1752,7 @@ public function testCountApplicantsQuery(): void ]), ]); // Should appear in searches, but in pool 2. + // group three PoolCandidate::factory()->create([ 'pool_id' => $pool2['id'], 'expiry_date' => config('constants.far_future_date'), @@ -1761,6 +1764,7 @@ public function testCountApplicantsQuery(): void ]), ]); // Expired in pool - should not appear in searches + // group four PoolCandidate::factory()->create([ 'pool_id' => $pool1['id'], 'expiry_date' => '2000-01-01', @@ -1772,6 +1776,7 @@ public function testCountApplicantsQuery(): void ]), ]); // Already placed - should appear in searches + // group five PoolCandidate::factory()->create([ 'pool_id' => $pool1['id'], 'expiry_date' => config('constants.far_future_date'), @@ -1784,6 +1789,7 @@ public function testCountApplicantsQuery(): void ]), ]); // User status inactive - should not appear in searches + // group six PoolCandidate::factory()->create([ 'pool_id' => $pool1['id'], 'expiry_date' => config('constants.far_future_date'), @@ -1813,6 +1819,7 @@ public function testCountApplicantsQuery(): void ); $response->assertJson([ 'data' => [ + // contains groups one, two, and five 'countApplicants' => 15, // including base admin user ], ]); @@ -1835,7 +1842,8 @@ public function testCountApplicantsQuery(): void ] )->assertJson([ 'data' => [ - 'countApplicants' => 10, //including base admin user + // counts groups one and five, filtered out two due to added language + 'countApplicants' => 10, // including base admin user ], ]); } From f33a75f276288d63cef9a278f176045b337c7ee2 Mon Sep 17 00:00:00 2001 From: vd1992 <40485260+vd1992@users.noreply.github.com> Date: Wed, 18 Dec 2024 13:15:32 -0700 Subject: [PATCH 10/10] phpstan --- api/app/Console/Commands/SuspendPlacedCandidates.php | 1 + api/app/Models/PoolCandidate.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/api/app/Console/Commands/SuspendPlacedCandidates.php b/api/app/Console/Commands/SuspendPlacedCandidates.php index a72a5a65078..4c01e87addb 100644 --- a/api/app/Console/Commands/SuspendPlacedCandidates.php +++ b/api/app/Console/Commands/SuspendPlacedCandidates.php @@ -38,6 +38,7 @@ public function handle() ->with('user') ->chunkById(100, function (Collection $candidates) { foreach ($candidates as $candidate) { + /** @var \App\Models\PoolCandidate $candidate */ $candidate->suspended_at = Carbon::now(); $candidate->save(); } diff --git a/api/app/Models/PoolCandidate.php b/api/app/Models/PoolCandidate.php index 1b6dadcb303..2f95d9c3e38 100644 --- a/api/app/Models/PoolCandidate.php +++ b/api/app/Models/PoolCandidate.php @@ -48,7 +48,7 @@ * @property ?int $status_weight * @property string $pool_id * @property string $user_id - * @property ?\Illuminate\Support\Carbon $suspended_at + * @property ?\Carbon\Carbon $suspended_at * @property \Illuminate\Support\Carbon $created_at * @property ?\Illuminate\Support\Carbon $updated_at * @property array $submitted_steps