Skip to content

Commit

Permalink
refactor(api): change id params to named params on campaign-stats-rou…
Browse files Browse the repository at this point in the history
…te.js
  • Loading branch information
Alexandre-Monney authored Nov 26, 2024
1 parent 1011198 commit e66908d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as participationsCountByMasteryRateSerializer from '../infrastructure/s

const getParticipationsByStage = async function (request) {
const { userId } = request.auth.credentials;
const campaignId = request.params.id;
const { campaignId } = request.params;

const participationsByStage = await usecases.getCampaignParticipationsCountByStage({ userId, campaignId });

Expand All @@ -18,7 +18,7 @@ const getParticipationsByStage = async function (request) {

const getParticipationsByStatus = async function (request) {
const { userId } = request.auth.credentials;
const campaignId = request.params.id;
const { campaignId } = request.params;

const participantsCounts = await usecases.getCampaignParticipationsCountsByStatus({ userId, campaignId });

Expand All @@ -29,7 +29,7 @@ const getParticipationsByStatus = async function (request) {
};
const getParticipationsByDay = async function (request) {
const { userId } = request.auth.credentials;
const campaignId = request.params.id;
const { campaignId } = request.params;

const participantsCounts = await usecases.getCampaignParticipationsActivityByDay({ userId, campaignId });

Expand All @@ -41,7 +41,7 @@ const getParticipationsByDay = async function (request) {

const getParticipationsCountByMasteryRate = async function (request) {
const { userId } = request.auth.credentials;
const campaignId = request.params.id;
const { campaignId } = request.params;

const resultDistribution = await usecases.getParticipationsCountByMasteryRate({ userId, campaignId });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ const register = async function (server) {
server.route([
{
method: 'GET',
path: '/api/campaigns/{id}/stats/participations-by-stage',
path: '/api/campaigns/{campaignId}/stats/participations-by-stage',
config: {
validate: {
params: Joi.object({ id: identifiersType.campaignId }),
params: Joi.object({ campaignId: identifiersType.campaignId }),
},
handler: campaignStatsController.getParticipationsByStage,
notes: [
Expand All @@ -22,10 +22,10 @@ const register = async function (server) {
},
{
method: 'GET',
path: '/api/campaigns/{id}/stats/participations-by-status',
path: '/api/campaigns/{campaignId}/stats/participations-by-status',
config: {
validate: {
params: Joi.object({ id: identifiersType.campaignId }),
params: Joi.object({ campaignId: identifiersType.campaignId }),
},
handler: campaignStatsController.getParticipationsByStatus,
notes: [
Expand All @@ -37,10 +37,10 @@ const register = async function (server) {
},
{
method: 'GET',
path: '/api/campaigns/{id}/stats/participations-by-day',
path: '/api/campaigns/{campaignId}/stats/participations-by-day',
config: {
validate: {
params: Joi.object({ id: identifiersType.campaignId }),
params: Joi.object({ campaignId: identifiersType.campaignId }),
},
handler: campaignStatsController.getParticipationsByDay,
notes: [
Expand All @@ -52,10 +52,10 @@ const register = async function (server) {
},
{
method: 'GET',
path: '/api/campaigns/{id}/stats/participations-by-mastery-rate',
path: '/api/campaigns/{campaignId}/stats/participations-by-mastery-rate',
config: {
validate: {
params: Joi.object({ id: identifiersType.campaignId }),
params: Joi.object({ campaignId: identifiersType.campaignId }),
},
handler: campaignStatsController.getParticipationsCountByMasteryRate,
notes: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Acceptance | API | Campaign Stats Route', function () {
server = await createServer();
});

describe('GET /api/campaigns/{id}/stats/participations-by-stage', function () {
describe('GET /api/campaigns/{campaignId}/stats/participations-by-stage', function () {
it('should return the campaign by id', async function () {
// given
const learningContentObjects = learningContentBuilder.fromAreas([
Expand Down Expand Up @@ -101,7 +101,7 @@ describe('Acceptance | API | Campaign Stats Route', function () {
});
});

describe('GET /api/campaigns/{id}/stats/participations-by-status', function () {
describe('GET /api/campaigns/{campaignId}/stats/participations-by-status', function () {
it('should return participations counts by status for the campaign', async function () {
// given
const campaign = databaseBuilder.factory.buildCampaign();
Expand Down Expand Up @@ -140,7 +140,7 @@ describe('Acceptance | API | Campaign Stats Route', function () {
});
});

describe('GET /api/campaigns/{id}/stats/participations-by-day', function () {
describe('GET /api/campaigns/{campaignId}/stats/participations-by-day', function () {
it('should return the activity by day', async function () {
// given
const campaign = databaseBuilder.factory.buildCampaign();
Expand Down Expand Up @@ -168,7 +168,7 @@ describe('Acceptance | API | Campaign Stats Route', function () {
});
});

describe('GET /api/campaigns/{id}/stats/participations-by-mastery-rate', function () {
describe('GET /api/campaigns/{campaignId}/stats/participations-by-mastery-rate', function () {
it('should return the mastery rate distribution', async function () {
const { id: userId } = databaseBuilder.factory.buildUser();
const { id: organizationId } = databaseBuilder.factory.buildOrganization();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as moduleUnderTest from '../../../../../src/prescription/campaign/appli
import { expect, HttpTestServer, sinon } from '../../../../test-helper.js';

describe('Unit | Application | Router | campaign-router ', function () {
describe('GET /api/campaigns/{id}/stats/participations-by-stage', function () {
describe('GET /api/campaigns/{campaignId}/stats/participations-by-stage', function () {
it('should return 200', async function () {
// given
sinon
Expand Down Expand Up @@ -32,7 +32,7 @@ describe('Unit | Application | Router | campaign-router ', function () {
});
});

describe('GET /api/campaigns/{id}/stats/participations-by-status', function () {
describe('GET /api/campaigns/{campaignId}/stats/participations-by-status', function () {
it('should return 200', async function () {
sinon
.stub(campaignStatsController, 'getParticipationsByStatus')
Expand All @@ -58,7 +58,7 @@ describe('Unit | Application | Router | campaign-router ', function () {
});
});

describe('GET /api/campaigns/{id}/stats/participations-by-mastery-rate', function () {
describe('GET /api/campaigns/{campaignId}/stats/participations-by-mastery-rate', function () {
beforeEach(function () {
sinon
.stub(campaignStatsController, 'getParticipationsCountByMasteryRate')
Expand Down

0 comments on commit e66908d

Please sign in to comment.