Skip to content

Commit

Permalink
tech(api): migrate particpant result usecase to its bounded-context
Browse files Browse the repository at this point in the history
  • Loading branch information
xav-car authored Nov 6, 2024
1 parent 350f3b8 commit b986fd5
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 22 deletions.
2 changes: 0 additions & 2 deletions api/lib/domain/usecases/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ import * as membershipRepository from '../../infrastructure/repositories/members
import * as organizationLearnerRepository from '../../infrastructure/repositories/organization-learner-repository.js';
import * as organizationMemberIdentityRepository from '../../infrastructure/repositories/organization-member-identity-repository.js';
import * as organizationTagRepository from '../../infrastructure/repositories/organization-tag-repository.js';
import * as participantResultRepository from '../../infrastructure/repositories/participant-result-repository.js';
import { participantResultsSharedRepository } from '../../infrastructure/repositories/participant-results-shared-repository.js';
import * as studentRepository from '../../infrastructure/repositories/student-repository.js';
import * as targetProfileForUpdateRepository from '../../infrastructure/repositories/target-profile-for-update-repository.js';
Expand Down Expand Up @@ -291,7 +290,6 @@ const dependencies = {
organizationRepository,
organizationTagRepository,
organizationValidator,
participantResultRepository,
participantResultsSharedRepository,
passwordGenerator,
passwordValidator,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
/* eslint-disable import/no-restricted-paths */
import * as defaultCompareStageAndAcquiredStagesService from '../../../src/evaluation/domain/services/stages/stage-and-stage-acquisition-comparison-service.js';
import * as defaultStageAcquisitionRepository from '../../../src/evaluation/infrastructure/repositories/stage-acquisition-repository.js';
import * as defaultStageRepository from '../../../src/evaluation/infrastructure/repositories/stage-repository.js';
import { NoCampaignParticipationForUserAndCampaign, NotFoundError } from '../../../src/shared/domain/errors.js';
import { CampaignParticipationStatuses } from '../../../src/shared/domain/models/index.js';
import * as defaultParticipantResultRepository from '../../infrastructure/repositories/participant-result-repository.js';
import { NoCampaignParticipationForUserAndCampaign, NotFoundError } from '../../../../shared/domain/errors.js';
import { CampaignParticipationStatuses } from '../../../../shared/domain/models/index.js';

const getUserCampaignAssessmentResult = async function ({
userId,
Expand All @@ -14,10 +8,10 @@ const getUserCampaignAssessmentResult = async function ({
badgeRepository,
knowledgeElementRepository,
badgeForCalculationRepository,
stageRepository = defaultStageRepository,
stageAcquisitionRepository = defaultStageAcquisitionRepository,
participantResultRepository = defaultParticipantResultRepository,
compareStagesAndAcquiredStages = defaultCompareStageAndAcquiredStagesService,
participantResultRepository,
stageRepository,
stageAcquisitionRepository,
compareStagesAndAcquiredStages,
}) {
const { SHARED, TO_SHARE } = CampaignParticipationStatuses;
const campaignParticipationStatus = await participantResultRepository.getCampaignParticipationStatus({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';

import * as badgeAcquisitionRepository from '../../../../../lib/infrastructure/repositories/badge-acquisition-repository.js';
import * as badgeForCalculationRepository from '../../../../../lib/infrastructure/repositories/badge-for-calculation-repository.js';
import * as campaignRepository from '../../../../../lib/infrastructure/repositories/campaign-repository.js';
import * as knowledgeElementRepository from '../../../../../lib/infrastructure/repositories/knowledge-element-repository.js';
import * as learningContentRepository from '../../../../../lib/infrastructure/repositories/learning-content-repository.js';
// TODO : use an API for this import
import * as organizationLearnerRepository from '../../../../../lib/infrastructure/repositories/organization-learner-repository.js';
import * as stageCollectionRepository from '../../../../../lib/infrastructure/repositories/user-campaign-results/stage-collection-repository.js';
import * as badgeRepository from '../../../../../src/evaluation/infrastructure/repositories/badge-repository.js';
import * as tutorialRepository from '../../../../devcomp/infrastructure/repositories/tutorial-repository.js';
import * as compareStagesAndAcquiredStages from '../../../../evaluation/domain/services/stages/stage-and-stage-acquisition-comparison-service.js';
import * as competenceEvaluationRepository from '../../../../evaluation/infrastructure/repositories/competence-evaluation-repository.js';
import * as stageAcquisitionRepository from '../../../../evaluation/infrastructure/repositories/stage-acquisition-repository.js';
import * as stageRepository from '../../../../evaluation/infrastructure/repositories/stage-repository.js';
import * as areaRepository from '../../../../shared/infrastructure/repositories/area-repository.js';
import * as assessmentRepository from '../../../../shared/infrastructure/repositories/assessment-repository.js';
import * as competenceRepository from '../../../../shared/infrastructure/repositories/competence-repository.js';
Expand All @@ -20,38 +24,76 @@ import * as campaignAssessmentParticipationRepository from '../../infrastructure
import * as campaignAssessmentParticipationResultRepository from '../../infrastructure/repositories/campaign-assessment-participation-result-repository.js';
import * as campaignParticipationRepository from '../../infrastructure/repositories/campaign-participation-repository.js';
import * as campaignProfileRepository from '../../infrastructure/repositories/campaign-profile-repository.js';
import { repositories as campaignRepositories } from '../../infrastructure/repositories/index.js';
import { repositories as campaignRepositories } from '../../infrastructure/repositories/index.js'; // needed to includes organizationFeatureAPI from another BC
import { participationResultCalculationJobRepository } from '../../infrastructure/repositories/jobs/participation-result-calculation-job-repository.js';
import { participationSharedJobRepository } from '../../infrastructure/repositories/jobs/participation-shared-job-repository.js';
import { participationStartedJobRepository } from '../../infrastructure/repositories/jobs/participation-started-job-repository.js';
import * as participantResultRepository from '../../infrastructure/repositories/participant-result-repository.js';
import * as participationsForCampaignManagementRepository from '../../infrastructure/repositories/participations-for-campaign-management-repository.js';
import * as participationsForUserManagementRepository from '../../infrastructure/repositories/participations-for-user-management-repository.js';
import * as poleEmploiSendingRepository from '../../infrastructure/repositories/pole-emploi-sending-repository.js';
/**
* @typedef { import ('../../../../shared/infrastructure/repositories/area-repository.js')} AreaRepository
* @typedef { import ('../../../../shared/infrastructure/repositories/assessment-repository.js')} AssessmentRepository
* @typedef { import ('../../../../../lib/infrastructure/repositories/badge-acquisition-repository.js')} BadgeAcquisitionRepository
* @typedef { import ('../../../../../lib/infrastructure/repositories/badge-for-calculation-repository.js')} BadgeForCalculationRepository
* @typedef { import ('../../../../../src/evaluation/infrastructure/repositories/badge-repository.js')} BadgeRepository
* @typedef { import ('../../infrastructure/repositories/campaign-analysis-repository.js')} CampaignAnalysisRepository
* @typedef { import ('../../infrastructure/repositories/campaign-assessment-participation-repository.js')} CampaignAssessmentParticipationRepository
* @typedef { import ('../../infrastructure/repositories/campaign-assessment-participation-result-repository.js')} CampaignAssessmentParticipationResultRepository
* @typedef { import ('../../infrastructure/repositories/index.js')} CampaignParticipantRepository
* @typedef { import ('../../infrastructure/repositories/campaign-participation-repository.js')} CampaignParticipationRepository
* @typedef { import ('../../infrastructure/repositories/campaign-profile-repository.js')} CampaignProfileRepository
* @typedef { import ('../../../../../lib/infrastructure/repositories/campaign-repository.js')} CampaignRepository
* @typedef { import ('../../../../evaluation/domain/services/stages/stage-and-stage-acquisition-comparison-service.js')} CompareStagesAndAcquiredStages
* @typedef { import ('../../../../evaluation/infrastructure/repositories/competence-evaluation-repository.js')} CompetenceEvaluationRepository
* @typedef { import ('../../../../shared/infrastructure/repositories/competence-repository.js')} CompetenceRepository
* @typedef { import ('../../../../../lib/infrastructure/repositories/knowledge-element-repository.js')} KnowledgeElementRepository
* @typedef { import ('../../../../../lib/infrastructure/repositories/learning-content-repository.js')} LearningContentRepository
* @typedef { import ('../../../../../lib/infrastructure/repositories/organization-learner-repository.js')} OrganizationLearnerRepository
* @typedef { import ('../../infrastructure/repositories/participant-result-repository.js')} ParticipantResultRepository
* @typedef { import ('../../infrastructure/repositories/jobs/participation-result-calculation-job-repository.js')} ParticipationResultCalculationJobRepository
* @typedef { import ('../../infrastructure/repositories/participations-for-campaign-management-repository.js')} ParticipationsForCampaignManagementRepository
* @typedef { import ('../../infrastructure/repositories/participations-for-user-management-repository.js')} ParticipationsForUserManagementRepository
* @typedef { import ('../../infrastructure/repositories/jobs/participation-shared-job-repository.js')} ParticipationSharedJobRepository
* @typedef { import ('../../infrastructure/repositories/jobs/participation-started-job-repository.js')} ParticipationStartedJobRepository
* @typedef { import ('../../infrastructure/repositories/pole-emploi-sending-repository.js')} PoleEmploiSendingRepository
* @typedef { import ('../../../../evaluation/infrastructure/repositories/stage-acquisition-repository.js')} StageAcquisitionRepository
* @typedef { import ('../../../../../lib/infrastructure/repositories/user-campaign-results/stage-collection-repository.js')} StageCollectionRepository
* @typedef { import ('../../../../evaluation/infrastructure/repositories/stage-repository.js')} StageRepository
* @typedef { import ('../../../../devcomp/infrastructure/repositories/tutorial-repository.js')} TutorialRepository
*/

const dependencies = {
areaRepository,
competenceRepository,
assessmentRepository,
badgeAcquisitionRepository,
badgeForCalculationRepository,
badgeRepository,
campaignAnalysisRepository,
campaignAssessmentParticipationRepository,
campaignAssessmentParticipationResultRepository,
campaignParticipantRepository: campaignRepositories.campaignParticipantRepository,
campaignParticipationRepository,
campaignProfileRepository,
campaignRepository,
compareStagesAndAcquiredStages,
competenceEvaluationRepository,
competenceRepository,
knowledgeElementRepository,
learningContentRepository,
organizationLearnerRepository,
participantResultRepository,
participationResultCalculationJobRepository,
participationsForCampaignManagementRepository,
participationsForUserManagementRepository,
participationSharedJobRepository,
participationStartedJobRepository,
poleEmploiSendingRepository,
stageAcquisitionRepository,
stageCollectionRepository,
stageRepository,
tutorialRepository,
organizationLearnerRepository,
};

const path = dirname(fileURLToPath(import.meta.url));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { getUserCampaignAssessmentResult } from '../../../../lib/domain/usecases/get-user-campaign-assessment-result.js';
import { NoCampaignParticipationForUserAndCampaign, NotFoundError } from '../../../../src/shared/domain/errors.js';
import { CampaignParticipationStatuses } from '../../../../src/shared/domain/models/index.js';
import { catchErr, domainBuilder, expect, sinon } from '../../../test-helper.js';
import { getUserCampaignAssessmentResult } from '../../../../../../src/prescription/campaign-participation/domain/usecases/get-user-campaign-assessment-result.js';
import {
NoCampaignParticipationForUserAndCampaign,
NotFoundError,
} from '../../../../../../src/shared/domain/errors.js';
import { CampaignParticipationStatuses } from '../../../../../../src/shared/domain/models/index.js';
import { catchErr, domainBuilder, expect, sinon } from '../../../../../test-helper.js';

describe('Unit | UseCase | get-user-campaign-assessment-result', function () {
const locale = 'locale',
Expand Down

0 comments on commit b986fd5

Please sign in to comment.