Skip to content

Commit

Permalink
[TECH] 🪓 suppression de la route `/api/users/{userId}/campaign-partic…
Browse files Browse the repository at this point in the history
…ipations` (Pix-15301)

 #10545
  • Loading branch information
pix-service-auto-merge authored Nov 18, 2024
2 parents 0969381 + 5e4d700 commit 8a8d2fd
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 451 deletions.
26 changes: 0 additions & 26 deletions api/lib/application/users/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,32 +166,6 @@ const register = async function (server) {

server.route([
...adminRoutes,
{
method: 'GET',
path: '/api/users/{id}/campaign-participations',
config: {
pre: [
{
method: securityPreHandlers.checkRequestedUserIsAuthenticatedUser,
assign: 'requestedUserIsAuthenticatedUser',
},
],
validate: {
params: Joi.object({
id: identifiersType.userId,
}),
},
handler: userController.getCampaignParticipations,
notes: [
'- **Cette route est restreinte aux utilisateurs authentifiés**\n' +
'- Récupération des participations à des campagnes à partir de l’id\n' +
'- L’id demandé doit correspondre à celui de l’utilisateur authentifié' +
'- Les participations aux campagnes sont triées par ordre inverse de création' +
' (les plus récentes en premier)',
],
tags: ['api'],
},
},
{
method: 'GET',
path: '/api/users/{id}/trainings',
Expand Down
10 changes: 0 additions & 10 deletions api/lib/application/users/user-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as trainingSerializer from '../../../src/devcomp/infrastructure/seriali
import { evaluationUsecases } from '../../../src/evaluation/domain/usecases/index.js';
import * as scorecardSerializer from '../../../src/evaluation/infrastructure/serializers/jsonapi/scorecard-serializer.js';
import * as userDetailsForAdminSerializer from '../../../src/identity-access-management/infrastructure/serializers/jsonapi/user-details-for-admin.serializer.js';
import * as campaignParticipationSerializer from '../../../src/prescription/campaign-participation/infrastructure/serializers/jsonapi/campaign-participation-serializer.js';
import * as certificationCenterMembershipSerializer from '../../../src/shared/infrastructure/serializers/jsonapi/certification-center-membership.serializer.js';
import * as userSerializer from '../../../src/shared/infrastructure/serializers/jsonapi/user-serializer.js';
import * as requestResponseUtils from '../../../src/shared/infrastructure/utils/request-response-utils.js';
Expand Down Expand Up @@ -48,14 +47,6 @@ const findPaginatedUserRecommendedTrainings = async function (
return dependencies.trainingSerializer.serialize(userRecommendedTrainings, meta);
};

const getCampaignParticipations = function (request, h, dependencies = { campaignParticipationSerializer }) {
const authenticatedUserId = request.auth.credentials.userId;

return usecases
.findLatestOngoingUserCampaignParticipations({ userId: authenticatedUserId })
.then(dependencies.campaignParticipationSerializer.serialize);
};

const resetScorecard = function (request, h, dependencies = { scorecardSerializer, requestResponseUtils }) {
const authenticatedUserId = request.auth.credentials.userId;
const competenceId = request.params.competenceId;
Expand Down Expand Up @@ -132,7 +123,6 @@ const userController = {
findCertificationCenterMembershipsByUser,
findPaginatedUserRecommendedTrainings,
findUserOrganizationsForAdmin,
getCampaignParticipations,
reassignAuthenticationMethods,
rememberUserHasSeenAssessmentInstructions,
rememberUserHasSeenChallengeTooltip,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -45,35 +45,6 @@ const get = async function (id) {
});
};

const findLatestOngoingByUserId = async function (userId) {
const campaignParticipations = await knex('campaign-participations')
.join('campaigns', 'campaigns.id', 'campaign-participations.campaignId')
.whereNull('campaigns.archivedAt')
.where({ userId })
.orderBy('campaign-participations.createdAt', 'DESC')
.select('campaign-participations.*');
const campaigns = await knex('campaigns').whereIn(
'id',
campaignParticipations.map((campaignParticipation) => campaignParticipation.campaignId),
);
const assessments = await knex('assessments')
.whereIn(
'campaignParticipationId',
campaignParticipations.map((campaignParticipation) => campaignParticipation.id),
)
.orderBy('createdAt');
return campaignParticipations.map((campaignParticipation) => {
const campaign = campaigns.find((campaign) => campaign.id === campaignParticipation.campaignId);
return new CampaignParticipation({
...campaignParticipation,
campaign: new Campaign(campaign),
assessments: assessments
.filter((assessment) => assessment.campaignParticipationId === campaignParticipation.id)
.map((assessment) => new Assessment(assessment)),
});
});
};

const isRetrying = async function ({ campaignParticipationId }) {
const { id: campaignId, userId } = await knex('campaigns')
.select('campaigns.id', 'userId')
Expand All @@ -91,10 +62,4 @@ const isRetrying = async function ({ campaignParticipationId }) {
);
};

export {
findLatestOngoingByUserId,
get,
getCodeOfLastParticipationToProfilesCollectionCampaignForUser,
hasAssessmentParticipations,
isRetrying,
};
export { get, getCodeOfLastParticipationToProfilesCollectionCampaignForUser, hasAssessmentParticipations, isRetrying };

This file was deleted.

Loading

0 comments on commit 8a8d2fd

Please sign in to comment.