-
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.
feat(api): get features of organization learner
- Loading branch information
1 parent
526a151
commit 9e6ad23
Showing
11 changed files
with
132 additions
and
6 deletions.
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
25 changes: 25 additions & 0 deletions
25
api/db/migrations/20241106164209_add-index-on-organization-learner-features.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,25 @@ | ||
// Make sure you properly test your migration, especially DDL (Data Definition Language) | ||
// ! If the target table is large, and the migration take more than 20 minutes, the deployment will fail ! | ||
|
||
// You can design and test your migration to avoid this by following this guide | ||
// https://1024pix.atlassian.net/wiki/spaces/EDTDT/pages/3849323922/Cr+er+une+migration | ||
|
||
// If your migrations target `answers` or `knowledge-elements` | ||
// contact @team-captains, because automatic migrations are not active on `pix-datawarehouse-production` | ||
// this may prevent data replication to succeed the day after your migration is deployed on `pix-api-production` | ||
const TABLE_NAME = 'organization-learner-features'; | ||
const COLUMN_NAME = 'organizationLearnerId'; | ||
|
||
const up = async function (knex) { | ||
await knex.schema.table(TABLE_NAME, function (table) { | ||
table.index(COLUMN_NAME); | ||
}); | ||
}; | ||
|
||
const down = async function (knex) { | ||
await knex.schema.table(TABLE_NAME, function (table) { | ||
table.dropIndex(COLUMN_NAME); | ||
}); | ||
}; | ||
|
||
export { down, up }; |
5 changes: 3 additions & 2 deletions
5
api/src/prescription/organization-learner/application/api/models/OrganizationLearner.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 |
---|---|---|
@@ -1,9 +1,10 @@ | ||
export class OrganizationLearner { | ||
constructor({ id, firstName, lastName, organizationId, ...attributes }) { | ||
constructor({ id, firstName, lastName, features, organizationId, ...attributes }) { | ||
this.id = id; | ||
this.firstName = firstName; | ||
this.lastName = lastName; | ||
this.division = attributes['Libellé classe']; | ||
this.features = features; | ||
this.organizationId = organizationId; | ||
this.division = attributes['Libellé classe']; | ||
} | ||
} |
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
12 changes: 11 additions & 1 deletion
12
api/src/school/domain/read-models/OrganizationLearnerDTO.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
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 |
---|---|---|
|
@@ -47,6 +47,23 @@ describe('Integration | Infrastructure | Repository | Organization Learner', fun | |
expect(organizationLearner.email).to.equal('[email protected]'); | ||
expect(organizationLearner.username).to.equal('sassouk'); | ||
expect(organizationLearner.organizationId).to.equal(organizationId); | ||
expect(organizationLearner.features).to.be.empty; | ||
}); | ||
|
||
it("Should return organization learner's features", async function () { | ||
const organizationLearnerId = databaseBuilder.factory.buildOrganizationLearner().id; | ||
databaseBuilder.factory.prescription.organizationLearners.buildOrganizationLearnerFeatureWithFeatureKey({ | ||
organizationLearnerId, | ||
featureKey: 'ORALIZATION', | ||
}); | ||
databaseBuilder.factory.prescription.organizationLearners.buildOrganizationLearnerFeatureWithFeatureKey({ | ||
organizationLearnerId, | ||
featureKey: 'BLA', | ||
}); | ||
await databaseBuilder.commit(); | ||
|
||
const organizationLearner = await organizationLearnerRepository.get({ organizationLearnerId }); | ||
expect(organizationLearner.features).to.deep.equal(['ORALIZATION', 'BLA']); | ||
}); | ||
|
||
it('Should return the organization learner with a given ID', async function () { | ||
|
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