Skip to content

Commit

Permalink
[Feature] Revert "[Feature] Opt into search placed candidates backend (
Browse files Browse the repository at this point in the history
…#12330)" (#12488)

* Revert "[Feature] Opt into search placed candidates backend (#12330)"

This reverts commit c776307.

* fix linting
  • Loading branch information
brindasasi authored Jan 15, 2025
1 parent 145ac54 commit 86676c3
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 220 deletions.
50 changes: 0 additions & 50 deletions api/app/Console/Commands/SuspendPlacedCandidates.php

This file was deleted.

3 changes: 0 additions & 3 deletions api/app/Enums/PoolCandidateStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,12 @@ 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,
];
}

Expand Down
8 changes: 0 additions & 8 deletions api/app/GraphQL/Mutations/PlaceCandidate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\GraphQL\Mutations;

use App\Enums\PlacementType;
use App\Models\PoolCandidate;
use Carbon\Carbon;

Expand All @@ -26,13 +25,6 @@ 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 {
$candidate->suspended_at = null;
}

$candidate->save();

return $candidate;
Expand Down
1 change: 0 additions & 1 deletion api/app/GraphQL/Mutations/RevertPlaceCandidate.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ 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();

Expand Down
2 changes: 1 addition & 1 deletion api/app/GraphQL/Queries/CountPoolCandidatesByPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __invoke($_, array $args)
}
});

// available candidates scope (qualifiedEquivalentGroup, not expired, not suspended)
// available candidates scope (scope CANDIDATE_STATUS_QUALIFIED_AVAILABLE or CANDIDATE_STATUS_PLACED_CASUAL, or PLACED_TENTATIVE)
PoolCandidate::scopeAvailable($queryBuilder);

// Only display IT & OTHER publishing group candidates
Expand Down
2 changes: 1 addition & 1 deletion api/app/Models/PoolCandidate.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
* @property ?int $status_weight
* @property string $pool_id
* @property string $user_id
* @property ?\Carbon\Carbon $suspended_at
* @property ?\Illuminate\Support\Carbon $suspended_at
* @property \Illuminate\Support\Carbon $created_at
* @property ?\Illuminate\Support\Carbon $updated_at
* @property array $submitted_steps
Expand Down
54 changes: 0 additions & 54 deletions api/tests/Feature/CountPoolCandidatesByPoolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -828,58 +828,4 @@ 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();
PoolCandidate::factory()->availableInSearch()->create([
'pool_id' => $itPool,
'pool_candidate_status' => PoolCandidateStatus::PLACED_TERM->name,
'suspended_at' => null,
]);
PoolCandidate::factory()->availableInSearch()->create([
'pool_id' => $itPool,
'pool_candidate_status' => PoolCandidateStatus::PLACED_INDETERMINATE->name,
'suspended_at' => null,
]);
PoolCandidate::factory()->availableInSearch()->create([
'pool_id' => $itPool,
'pool_candidate_status' => PoolCandidateStatus::PLACED_TERM->name,
'suspended_at' => config('constants.far_past_datetime'),
]);

// expect 2, the 2 un-suspended ones
$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,
],
],
],
]);
}
}
33 changes: 0 additions & 33 deletions api/tests/Feature/PoolCandidateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
use Tests\TestCase;
use Tests\UsesProtectedGraphqlEndpoint;

use function PHPUnit\Framework\assertEqualsCanonicalizing;

class PoolCandidateTest extends TestCase
{
use MakesGraphQLRequests;
Expand Down Expand Up @@ -851,35 +849,4 @@ 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,
'expiry_date' => null,
'suspended_at' => null,
]);

$suspendedCandidate = PoolCandidate::factory()->availableInSearch()->create([
'pool_candidate_status' => PoolCandidateStatus::PLACED_TERM->name,
'expiry_date' => null,
'suspended_at' => config('constants.far_past_datetime'),
]);

$expiredCandidate = PoolCandidate::factory()->availableInSearch()->create([
'pool_candidate_status' => PoolCandidateStatus::PLACED_TERM->name,
'expiry_date' => config('constants.past_date'),
'suspended_at' => null,
]);

$queryBuilder = PoolCandidate::query();
$candidateIds = PoolCandidate::scopeAvailable($queryBuilder)->get()->pluck('id')->toArray();

// suspended and expired not present
assertEqualsCanonicalizing([
$candidate->id,
], $candidateIds);
}
}
57 changes: 0 additions & 57 deletions api/tests/Feature/PoolCandidateUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ protected function setUp(): void
placedDepartment {
id
}
suspendedAt
}
}
';
Expand All @@ -176,7 +175,6 @@ protected function setUp(): void
placedDepartment {
id
}
suspendedAt
}
}
';
Expand Down Expand Up @@ -504,66 +502,12 @@ 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 $placementType) {
$response = $this->actingAs($this->poolOperatorUser, 'api')
->graphQL(
$this->placeCandidateMutation,
[
'id' => $this->poolCandidate->id,
'placeCandidate' => [
'placementType' => $placementType,
'departmentId' => $department->id,
],
]
)->json('data.placeCandidate');

assertSame($response['status']['value'], $placementType);
assertNotNull($response['placedAt']);
assertNull($response['suspendedAt']);
}

foreach ($placedDoSuspend as $placementType) {
$response = $this->actingAs($this->poolOperatorUser, 'api')
->graphQL(
$this->placeCandidateMutation,
[
'id' => $this->poolCandidate->id,
'placeCandidate' => [
'placementType' => $placementType,
'departmentId' => $department->id,
],
]
)->json('data.placeCandidate');

assertSame($response['status']['value'], $placementType);
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
Expand Down Expand Up @@ -591,7 +535,6 @@ 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
Expand Down
15 changes: 3 additions & 12 deletions api/tests/Feature/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,6 @@ 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'),
Expand All @@ -1740,7 +1739,6 @@ 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'),
Expand All @@ -1752,7 +1750,6 @@ 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'),
Expand All @@ -1764,7 +1761,6 @@ 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',
Expand All @@ -1775,21 +1771,18 @@ public function testCountApplicantsQuery(): void
'looking_for_bilingual' => false,
]),
]);
// Already placed - should appear in searches
// group five
// Already placed - should not 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,
'looking_for_bilingual' => false,
]),
]);
// User status inactive - should not appear in searches
// group six
PoolCandidate::factory()->create([
'pool_id' => $pool1['id'],
'expiry_date' => config('constants.far_future_date'),
Expand Down Expand Up @@ -1819,8 +1812,7 @@ public function testCountApplicantsQuery(): void
);
$response->assertJson([
'data' => [
// contains groups one, two, and five
'countApplicants' => 15, // including base admin user
'countApplicants' => 14, // including base admin user
],
]);

Expand All @@ -1842,8 +1834,7 @@ public function testCountApplicantsQuery(): void
]
)->assertJson([
'data' => [
// counts groups one and five, filtered out two due to added language
'countApplicants' => 10, // including base admin user
'countApplicants' => 9, // including base admin user
],
]);
}
Expand Down

0 comments on commit 86676c3

Please sign in to comment.