Skip to content

Commit

Permalink
make seeds work
Browse files Browse the repository at this point in the history
  • Loading branch information
laura-bergoens committed Dec 2, 2024
1 parent 8637fce commit 7daa13f
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export function buildArea({
name = 'name Domaine A',
title_i18n = { fr: 'title FR Domaine A', en: 'title EN Domaine A' },
color = 'color Domaine A',
frameworkId = 'frameworkPix',
competenceIds = ['competenceIdA'],
frameworkId = null,
competenceIds = [],
} = {}) {
const values = {
id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export function buildChallenge({
embedUrl = 'embedUrl Epreuve A',
embedTitle = 'embedTitle Epreuve A',
locales = ['fr'],
competenceId = 'competenceIdA',
skillId = 'skillIdA',
competenceId = null,
skillId = null,
} = {}) {
const values = {
id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ export function buildCompetence({
description_i18n = { fr: 'description FR Compétence A', en: 'description EN Compétence A' },
index = 'index Compétence A',
origin = 'origin Compétence A',
areaId = 'areaIdA',
skillIds = ['skillIdA'],
thematicIds = ['thematicIdA'],
areaId = null,
skillIds = [],
thematicIds = [],
} = {}) {
const values = {
id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export function buildCourse({
name = 'instruction Test Statique A',
description = 'description Test Statique A',
isActive = true,
competences = ['competenceIdA'],
challenges = ['challengeIdA'],
competences = [],
challenges = [],
} = {}) {
const values = {
id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function buildMission({
introductionMediaAlt_i18n = { fr: 'introductionMediaAlt FR Mission A', en: 'introductionMediaAlt EN Mission A' },
documentationUrl = 'documentationUrl Mission A',
cardImageUrl = 'cardImageUrl Mission A',
competenceId = 'competenceIdA',
competenceId = null,
} = {}) {
const values = {
id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export function buildSkill({
version = 5,
level = 2,
hintStatus = 'hintStatus Acquis A',
competenceId = 'competenceIdA',
tubeId = 'tubeIdA',
tutorialIds = ['tutorialIdA'],
competenceId = null,
tubeId = null,
tutorialIds = [],
learningMoreTutorialIds = [],
hint_i18n = { fr: 'Un indice' },
} = {}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export function buildThematic({
id = 'thematicIdA',
name_i18n = { fr: 'name FR Thématique A', en: 'name EN Thématique A' },
index = 8,
competenceId = 'competenceIdA',
tubeIds = ['tubeIdA'],
competenceId = null,
tubeIds = [],
} = {}) {
const values = {
id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export function buildTube({
description = 'description Tube A',
practicalTitle_i18n = { fr: 'practicalTitle FR Tube A', en: 'practicalTitle EN Tube A' },
practicalDescription_i18n = { fr: 'practicalDescription FR Tube A', en: 'practicalDescription EN Tube A' },
competenceId = 'competenceIdA',
thematicId = 'thematicIdA',
skillIds = ['skillIdA'],
competenceId = null,
thematicId = null,
skillIds = [],
isMobileCompliant = true,
isTabletCompliant = true,
} = {}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@ async function loadWebComponentInfo(challengeDto) {

async function loadChallengeDtosSkills(challengeDtos) {
return Promise.all(
challengeDtos.map(async (challengeDto) => [challengeDto, await skillRepository.get(challengeDto.skillId)]),
challengeDtos.map(async (challengeDto) => [
challengeDto,
challengeDto.skillId ? await skillRepository.get(challengeDto.skillId) : null,
]),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ export class LearningContentRepository {
}

async load(id) {
if (!id) return null;
return this.#dataloader.load(id);
}

async loadMany(ids) {
return this.#dataloader.loadMany(ids);
const notNullIds = ids.filter((id) => id);
return this.#dataloader.loadMany(notNullIds);
}

#findDtos(callback, cacheKey) {
Expand Down

0 comments on commit 7daa13f

Please sign in to comment.