-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(lbac-2328): nettoyage de la collection application (#1751)
* fix(lbac-2328): nettoyage de la collection application * fix: nom de la collection * fix: tests * fix: tests
- Loading branch information
1 parent
1a06c40
commit 82b1817
Showing
16 changed files
with
153 additions
and
119 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { omit } from "lodash-es" | ||
import { ObjectId } from "mongodb" | ||
import { IApplicationApiPublic, JOB_STATUS } from "shared" | ||
import { NIVEAUX_POUR_LBA, RECRUITER_STATUS } from "shared/constants" | ||
|
@@ -141,15 +142,19 @@ describe("POST /v2/application", () => { | |
expect.soft(response.statusCode).toEqual(202) | ||
expect.soft(response.json()).toEqual({ id: application!._id.toString() }) | ||
|
||
expect.soft(omit(applicant, ["createdAt", "last_connection", "updatedAt"])).toEqual({ | ||
_id: applicant?._id, | ||
email: body.applicant_email, | ||
firstname: body.applicant_first_name, | ||
lastname: body.applicant_last_name, | ||
phone: body.applicant_phone, | ||
}) | ||
|
||
expect(application).toEqual({ | ||
_id: expect.any(ObjectId), | ||
applicant_id: applicant?._id, | ||
applicant_attachment_name: body.applicant_attachment_name, | ||
applicant_email: body.applicant_email, | ||
applicant_first_name: body.applicant_first_name, | ||
applicant_last_name: body.applicant_last_name, | ||
applicant_message_to_company: "", | ||
applicant_phone: body.applicant_phone, | ||
company_email: recruteur.email, | ||
company_feedback: null, | ||
company_name: "ASSEMBLEE NATIONALE", | ||
|
@@ -200,15 +205,19 @@ describe("POST /v2/application", () => { | |
expect.soft(response.statusCode).toEqual(202) | ||
expect.soft(response.json()).toEqual({ id: application!._id.toString() }) | ||
|
||
expect.soft(omit(applicant, ["createdAt", "last_connection", "updatedAt"])).toEqual({ | ||
_id: applicant?._id, | ||
email: body.applicant_email, | ||
firstname: body.applicant_first_name, | ||
lastname: body.applicant_last_name, | ||
phone: body.applicant_phone, | ||
}) | ||
|
||
expect(application).toEqual({ | ||
_id: expect.any(ObjectId), | ||
applicant_id: applicant?._id, | ||
applicant_attachment_name: body.applicant_attachment_name, | ||
applicant_email: body.applicant_email, | ||
applicant_first_name: body.applicant_first_name, | ||
applicant_last_name: body.applicant_last_name, | ||
applicant_message_to_company: "", | ||
applicant_phone: body.applicant_phone, | ||
company_address: "Paris", | ||
company_email: "[email protected]", | ||
company_feedback: null, | ||
|
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 was deleted.
Oops, something went wrong.
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
15 changes: 15 additions & 0 deletions
15
server/src/migrations/20250107000000-clean-applications.ts
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,15 @@ | ||
import { getDbCollection } from "@/common/utils/mongodbUtils" | ||
|
||
export const up = async () => { | ||
await getDbCollection("applications").updateMany( | ||
{}, | ||
{ | ||
$unset: { | ||
applicant_first_name: "", | ||
applicant_last_name: "", | ||
applicant_email: "", | ||
applicant_phone: "", | ||
}, | ||
} | ||
) | ||
} |
42 changes: 42 additions & 0 deletions
42
server/src/migrations/20250107000002-archive-applications.ts
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,42 @@ | ||
import { getDbCollection } from "@/common/utils/mongodbUtils" | ||
import { anonymizeApplicationProjection } from "@/jobs/anonymization/anonymizeApplications" | ||
|
||
export const up = async () => { | ||
const filterStages = [ | ||
{ | ||
$lookup: { | ||
from: "applicants", | ||
localField: "applicant_id", | ||
foreignField: "_id", | ||
as: "matches", | ||
}, | ||
}, | ||
{ | ||
$match: { | ||
"matches.0": { | ||
$exists: false, | ||
}, | ||
}, | ||
}, | ||
] | ||
await getDbCollection("applications") | ||
.aggregate([ | ||
...filterStages, | ||
{ | ||
$project: anonymizeApplicationProjection, | ||
}, | ||
{ | ||
$merge: "anonymized_applications", | ||
}, | ||
]) | ||
.toArray() | ||
const idsToDelete = await getDbCollection("applications") | ||
.aggregate([ | ||
...filterStages, | ||
{ | ||
$project: { _id: 1 }, | ||
}, | ||
]) | ||
.toArray() | ||
await getDbCollection("applications").deleteMany({ _id: { $in: idsToDelete.map(({ _id }) => _id) } }) | ||
} |
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.