-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TECH] Ecrire dans PG le contenu pédagogique lorsqu'on provoque la cr…
- Loading branch information
Showing
20 changed files
with
2,504 additions
and
60 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
api/src/learning-content/application/jobs/lcms-create-release-job-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { JobController } from '../../../shared/application/jobs/job-controller.js'; | ||
import { logger } from '../../../shared/infrastructure/utils/logger.js'; | ||
import { LcmsCreateReleaseJob } from '../../domain/models/LcmsCreateReleaseJob.js'; | ||
import { usecases } from '../../domain/usecases/index.js'; | ||
|
||
export class LcmsCreateReleaseJobController extends JobController { | ||
constructor() { | ||
super(LcmsCreateReleaseJob.name); | ||
} | ||
|
||
async handle() { | ||
try { | ||
await usecases.createLearningContentRelease(); | ||
logger.info('Learning Content cache updated with newly created release'); | ||
} catch (e) { | ||
logger.error('Error while updating cache with newly created release', e); | ||
throw e; | ||
} | ||
} | ||
} |
13 changes: 3 additions & 10 deletions
13
api/src/learning-content/application/learning-content-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
5 changes: 5 additions & 0 deletions
5
api/src/learning-content/domain/models/LcmsCreateReleaseJob.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,5 @@ | ||
export class LcmsCreateReleaseJob { | ||
constructor({ userId }) { | ||
this.userId = userId; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
api/src/learning-content/domain/usecases/create-learning-content-release.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,31 @@ | ||
import { withTransaction } from '../../../shared/domain/DomainTransaction.js'; | ||
|
||
export const createLearningContentRelease = withTransaction( | ||
/** @param {import('./dependencies.js').Dependencies} */ | ||
async function createLearningContentRelease({ | ||
LearningContentCache, | ||
frameworkRepository, | ||
areaRepository, | ||
competenceRepository, | ||
thematicRepository, | ||
tubeRepository, | ||
challengeRepository, | ||
skillRepository, | ||
courseRepository, | ||
tutorialRepository, | ||
missionRepository, | ||
}) { | ||
const learningContent = await LearningContentCache.instance.update(); | ||
|
||
await frameworkRepository.save(learningContent.frameworks); | ||
await areaRepository.save(learningContent.areas); | ||
await competenceRepository.save(learningContent.competences); | ||
await thematicRepository.save(learningContent.thematics); | ||
await tubeRepository.save(learningContent.tubes); | ||
await skillRepository.save(learningContent.skills); | ||
await challengeRepository.save(learningContent.challenges); | ||
await courseRepository.save(learningContent.courses); | ||
await tutorialRepository.save(learningContent.tutorials); | ||
await missionRepository.save(learningContent.missions); | ||
}, | ||
); |
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
10 changes: 10 additions & 0 deletions
10
api/src/learning-content/domain/usecases/schedule-create-learning-content-release-job.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,10 @@ | ||
import { LcmsCreateReleaseJob } from '../models/LcmsCreateReleaseJob.js'; | ||
|
||
/** | ||
* @param {{ | ||
* userId: number | ||
* } & import('./dependencies.js').Dependencies} | ||
*/ | ||
export async function scheduleCreateLearningContentReleaseJob({ userId, lcmsCreateReleaseJobRepository }) { | ||
await lcmsCreateReleaseJobRepository.performAsync(new LcmsCreateReleaseJob({ userId })); | ||
} |
13 changes: 13 additions & 0 deletions
13
...c/learning-content/infrastructure/repositories/jobs/lcms-create-release-job-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,13 @@ | ||
import { JobRepository, JobRetry } from '../../../../shared/infrastructure/repositories/jobs/job-repository.js'; | ||
import { LcmsCreateReleaseJob } from '../../../domain/models/LcmsCreateReleaseJob.js'; | ||
|
||
class LcmsCreateReleaseJobRepository extends JobRepository { | ||
constructor() { | ||
super({ | ||
name: LcmsCreateReleaseJob.name, | ||
retry: JobRetry.NO_RETRY, | ||
}); | ||
} | ||
} | ||
|
||
export const lcmsCreateReleaseJobRepository = new LcmsCreateReleaseJobRepository(); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.