Skip to content

Commit

Permalink
DROP ME ? feat: sort tubes according to index
Browse files Browse the repository at this point in the history
sub 30

Co-authored-by: Fael Bassetti <fael.bassetti@pix.fr>
  • Loading branch information
nlepage and fael-b committed Sep 16, 2024
1 parent d1a0091 commit 95770e4
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 6 deletions.
2 changes: 2 additions & 0 deletions api/lib/domain/models/Tube.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ export class Tube {
practicalTitle_i18n,
practicalDescription_i18n,
competenceId,
index,
}) {
this.id = id;
this.airtableId = airtableId;
this.name = name;
this.practicalTitle_i18n = practicalTitle_i18n;
this.practicalDescription_i18n = practicalDescription_i18n;
this.competenceId = competenceId;
this.index = index;
}
}
6 changes: 6 additions & 0 deletions api/lib/domain/readmodels/CompetenceOverview.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class CompetenceOverview {
id: tube.id,
airtableId: tube.airtableId,
name: tube.name,
index: tube.index,
enConstructionSkillViews: CompetenceOverview.#buildEnConstructionSkillViews({ locale, skills: skillsForTube, tutorials: tutorialsForCompetence }),
enProductionSkillViews: CompetenceOverview.#buildEnProductionSkillViews2({ locale, skills: skillsForTube, challenges: challengesForCompetence, tutorials: tutorialsForCompetence }),
atelierSkillViews: CompetenceOverview.#buildAtelierSkillViews({ locale, skills: skillsForTube, challenges: challengesForCompetence }),
Expand All @@ -38,6 +39,7 @@ export class CompetenceOverview {
airtableId: thematic.airtableId,
name: thematic.name_i18n['fr'],
tubeOverviews,
index: thematic.index,
}));
}
return new CompetenceOverview({
Expand Down Expand Up @@ -159,11 +161,13 @@ export class ThematicOverview {
airtableId,
name,
tubeOverviews,
index,
}) {
this.id = id;
this.airtableId = airtableId;
this.name = name;
this.tubeOverviews = tubeOverviews;
this.index = index;
}
}

Expand All @@ -175,13 +179,15 @@ export class TubeOverview {
enConstructionSkillViews,
atelierSkillViews,
enProductionSkillViews,
index,
}) {
this.id = id;
this.airtableId = airtableId;
this.name = name;
this.enConstructionSkillViews = enConstructionSkillViews;
this.atelierSkillViews = atelierSkillViews;
this.enProductionSkillViews = enProductionSkillViews;
this.index = index;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const tubeDatasource = datasource.extend({
'id persistant',
'Nom',
'Competences (id persistant)',
'Index',
],

fromAirTableObject(airtableRecord) {
Expand All @@ -23,6 +24,7 @@ export const tubeDatasource = datasource.extend({
name: airtableRecord.get('Nom'),
// FIXME remplacer par Competence (via Thematique) (id persistant) ?
competenceId: _.head(airtableRecord.get('Competences (id persistant)')),
index: airtableRecord.get('Index'),
};
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export function serialize(competenceOverview) {
'airtableId',
'name',
'tubeOverviews',
'index',
],
tubeOverviews: {
include: true,
Expand All @@ -37,6 +38,7 @@ export function serialize(competenceOverview) {
'enConstructionSkillViews',
'enProductionSkillViews',
'atelierSkillViews',
'index',
],
enConstructionSkillViews: {
include: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ async function mockCurrentContent() {

const expectedTube = domainBuilder.buildTube();
delete expectedTube.airtableId;
delete expectedTube.index;

const expectedCurrentContent = {
attachments: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ describe('Integration | Repository | tube-repository', () => {
fr: 'practicalDescriptionFrFr tube1',
en: 'practicalDescriptionEnUs tube1',
},
competenceId: 'competenceId'
competenceId: 'competenceId',
index: 1,
}),
airtableBuilder.factory.buildTube({
id: 'tubeId2',
Expand All @@ -34,7 +35,8 @@ describe('Integration | Repository | tube-repository', () => {
fr: 'practicalDescriptionFrFr tube2',
en: 'practicalDescriptionEnUs tube2',
},
competenceId: 'competenceId'
competenceId: 'competenceId',
index: 2,
}),
]).activate().nockScope;
const tube1DescriptionEn = databaseBuilder.factory.buildTranslation({
Expand Down Expand Up @@ -98,6 +100,7 @@ describe('Integration | Repository | tube-repository', () => {
en: tube1DescriptionEn.value,
},
competenceId: 'competenceId',
index: 1,
}),
domainBuilder.buildTube({
id: 'tubeId2',
Expand All @@ -112,6 +115,7 @@ describe('Integration | Repository | tube-repository', () => {
en: tube2DescriptionEn.value,
},
competenceId: 'competenceId',
index: 2,
}),
]);

Expand All @@ -135,6 +139,7 @@ describe('Integration | Repository | tube-repository', () => {
en: 'practicalDescriptionEnUs tube1',
},
competenceId: 'competenceId1',
index: 0,
};
const tube1DescriptionEn = databaseBuilder.factory.buildTranslation({
key: 'tube.tubeId1.practicalDescription',
Expand Down Expand Up @@ -166,6 +171,7 @@ describe('Integration | Repository | tube-repository', () => {
'id persistant': tube1.id,
'Nom': tube1.name,
'Competences (id persistant)': [tube1.competenceId],
'Index': tube1.index,
},
get: function(field) { return this.fields[field]; },
}];
Expand All @@ -189,6 +195,7 @@ describe('Integration | Repository | tube-repository', () => {
en: tube1DescriptionEn.value,
},
competenceId: 'competenceId1',
index: 0,
})
]);
});
Expand Down
2 changes: 2 additions & 0 deletions api/tests/tooling/airtable-builder/factory/build-tube.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export function buildTube({
id,
name,
competenceId,
index,
} = {}) {

return {
Expand All @@ -10,6 +11,7 @@ export function buildTube({
'id persistant': id,
'Nom': name,
'Competences (id persistant)': [competenceId],
'Index': index,
},
};
}
4 changes: 3 additions & 1 deletion api/tests/tooling/domain-builder/factory/build-tube.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export function buildTube({
fr: 'Identifier un navigateur web et un moteur de recherche, connaître le fonctionnement du moteur de recherche',
en: 'Identify a web browser and a search engine, know how the search engine works',
},
competenceId = 'recsvLz0W2ShyfD63'
competenceId = 'recsvLz0W2ShyfD63',
index = 0,
} = {}) {
return new Tube({
id,
Expand All @@ -21,5 +22,6 @@ export function buildTube({
practicalTitle_i18n,
practicalDescription_i18n,
competenceId,
index,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ export function buildTubeDatasourceObject(
airtableId,
name = '@Moteur',
competenceId = 'recsvLz0W2ShyfD63',
index = 0,
} = {}) {
return {
id,
airtableId: airtableId ?? id,
name,
competenceId,
index,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export function buildTube({
en: practicalDescriptionEnUs,
} = {},
competenceId,
index,
} = {}) {
return {
id,
Expand All @@ -21,6 +22,7 @@ export function buildTube({
'Description pratique fr-fr': practicalDescriptionFrFr,
'Description pratique en-us': practicalDescriptionEnUs,
'Competences (id persistant)': [competenceId],
'Index': index,
},
};
}
Loading

0 comments on commit 95770e4

Please sign in to comment.