-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TECH] Créer un nouvel assessment result lorsqu'on annule et désannule une certification sur Pix Admin (PIX-16045). #11131
Merged
pix-service-auto-merge
merged 8 commits into
dev
from
PIX-16045-create-assessment-result-when-status-cancelled
Feb 3, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
644069b
:sparkles: api: create cancelled status on assessment-result
Steph0 1b8c39c
:sparkles: new cancelled event
Steph0 6ce072b
feat(api): prevent session from being cancelled when already finalized
alexandrecoin 2f14255
:sparkles: feat(api): create cancel assessment result for V3 certif
yaf 9bea6e9
:recycle: calling rescoring synchronously without eventDispatcher
Steph0 191cd22
✨ api: uncancel route
AndreiaPena b5f8306
♻️ api: uncancel certification course after scoring (for V2 certifica…
AndreiaPena 321d6f0
:recycle: chore(api) rename variable and add comment
yaf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 6 additions & 2 deletions
8
api/src/certification/session-management/application/cancellation-controller.js
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
7 changes: 0 additions & 7 deletions
7
api/src/certification/session-management/domain/usecases/cancel-certification-course.js
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
api/src/certification/session-management/domain/usecases/cancel.js
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 @@ | ||
/** | ||
* @typedef {import('./index.js'.CertificationCourseRepository} CertificationCourseRepository | ||
* @typedef {import('./index.js'.SessionRepository} SessionRepository | ||
* @typedef {import('./index.js'.CertificationRescoringRepository} CertificationRescoringRepository | ||
*/ | ||
|
||
import CertificationCancelled from '../../../../../src/shared/domain/events/CertificationCancelled.js'; | ||
import { NotFinalizedSessionError } from '../../../../shared/domain/errors.js'; | ||
|
||
/** | ||
* @param {Object} params | ||
* @param {number} params.certificationCourseId | ||
* @param {CertificationCourseRepository} params.certificationCourseRepository | ||
* @param {SessionRepository} params.sessionRepository | ||
* @param {CertificationRescoringRepository} params.certificationRescoringRepository | ||
*/ | ||
export const cancel = async function ({ | ||
certificationCourseId, | ||
juryId, | ||
certificationCourseRepository, | ||
sessionRepository, | ||
certificationRescoringRepository, | ||
}) { | ||
const certificationCourse = await certificationCourseRepository.get({ id: certificationCourseId }); | ||
const session = await sessionRepository.get({ id: certificationCourse.getSessionId() }); | ||
if (!session.isFinalized) { | ||
throw new NotFinalizedSessionError(); | ||
} | ||
|
||
const event = new CertificationCancelled({ | ||
certificationCourseId, | ||
juryId, | ||
}); | ||
|
||
await certificationRescoringRepository.execute({ event }); | ||
|
||
// Note: update after event to ensure we doing it well, even when rescoring. Needeed this only for v2 certification | ||
certificationCourse.cancel(); | ||
await certificationCourseRepository.update({ certificationCourse }); | ||
}; |
7 changes: 0 additions & 7 deletions
7
api/src/certification/session-management/domain/usecases/uncancel-certification-course.js
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
api/src/certification/session-management/domain/usecases/uncancel.js
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 @@ | ||
/** | ||
* @typedef {import('./index.js'.CertificationCourseRepository} CertificationCourseRepository | ||
* @typedef {import('./index.js'.CertificationRescoringRepository} CertificationRescoringRepository | ||
* @typedef {import('./index.js'.SessionRepository} SessionRepository | ||
*/ | ||
|
||
import { NotFinalizedSessionError } from '../../../../shared/domain/errors.js'; | ||
import CertificationUncancelled from '../../../../shared/domain/events/CertificationUncancelled.js'; | ||
|
||
/** | ||
* @param {Object} params | ||
* @param {number} params.certificationCourseId | ||
* @param {number} params.juryId | ||
* @param {CertificationCourseRepository} params.certificationCourseRepository | ||
* @param {CertificationRescoringRepository} params.certificationRescoringRepository | ||
* @param {SessionRepository} params.SessionRepository | ||
*/ | ||
export const uncancel = async function ({ | ||
certificationCourseId, | ||
juryId, | ||
certificationCourseRepository, | ||
certificationRescoringRepository, | ||
sessionRepository, | ||
}) { | ||
const certificationCourse = await certificationCourseRepository.get({ id: certificationCourseId }); | ||
const session = await sessionRepository.get({ id: certificationCourse.getSessionId() }); | ||
if (!session.isFinalized) { | ||
throw new NotFinalizedSessionError(); | ||
} | ||
|
||
certificationCourse.uncancel(); | ||
await certificationCourseRepository.update({ certificationCourse }); | ||
|
||
const event = new CertificationUncancelled({ | ||
certificationCourseId: certificationCourse.getId(), | ||
juryId, | ||
}); | ||
|
||
return certificationRescoringRepository.execute({ event }); | ||
}; |
16 changes: 16 additions & 0 deletions
16
...tion/session-management/infrastructure/repositories/certification-rescoring-repository.js
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,16 @@ | ||
/** | ||
* @typedef {import('../../../../../src/shared/domain/events/CertificationCancelled.js'} CertificationCancelled | ||
* @typedef {import('../../../../../src/shared/domain/events/CertificationUncancelled.js'} CertificationUncancelled | ||
* @typedef {import('./index.js'.LibServices} LibServices | ||
*/ | ||
|
||
/** | ||
* @param {Object} params | ||
* @param {CertificationCancelled|CertificationUncancelled} params.event | ||
* @param {LibServices} params.libServices | ||
*/ | ||
export const execute = async ({ event, libServices }) => { | ||
return libServices.handleCertificationRescoring({ | ||
event, | ||
}); | ||
}; |
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,15 @@ | ||
import { assertNotNullOrUndefined } from '../models/asserts.js'; | ||
|
||
export default class CertificationCancelled { | ||
/** | ||
* @param {Object} params | ||
* @param {number} params.certificationCourseId - certification course that will be rescored | ||
* @param {number} params.juryId - Id of the jury member who cancelled the certification | ||
*/ | ||
constructor({ certificationCourseId, juryId }) { | ||
assertNotNullOrUndefined(certificationCourseId); | ||
this.certificationCourseId = certificationCourseId; | ||
assertNotNullOrUndefined(juryId); | ||
this.juryId = juryId; | ||
} | ||
} |
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 { assertNotNullOrUndefined } from '../models/asserts.js'; | ||
|
||
export default class CertificationUncancelled { | ||
/** | ||
* @param {Object} params | ||
* @param {number} params.certificationCourseId - certification course that will be rescored | ||
* @param {number} params.juryId - Id of the jury member who uncancelled the certification | ||
*/ | ||
constructor({ certificationCourseId, juryId }) { | ||
assertNotNullOrUndefined(certificationCourseId); | ||
this.certificationCourseId = certificationCourseId; | ||
assertNotNullOrUndefined(juryId); | ||
this.juryId = juryId; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comme c'est le mecanisme principal pour le moment, je propose de mettre comme dans uncancel, a savoir d'abord l'update avant l'event. Comme ca si l'event echoue, le update aura bien ete fait dans tous les cas.
De maniere generale d'ailleurs je trouve mieux une meilleure pratique que les operations locales soit toutes validees avant de propager un evenement a d'autres contextes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vu ensemble, c'est le fameux twist pour le scoring v2 => todo: faire un commentaire pour prévenir du choix d'appels dans cet ordre là