patch curriculum..

This commit is contained in:
2026-08-07 10:27:19 +09:00
parent f8ccd8b0a3
commit 196ba51ec6
9 changed files with 353 additions and 199 deletions
+2 -105
View File
@@ -1406,26 +1406,7 @@ export class InstructorService {
courseId: course.id,
},
});
const visualizationPlatforms = await this.prisma.visualizationPlatform.findMany({
where: { enabled: true },
orderBy: { sortOrder: 'asc' },
});
const tagOptions = await this.findCurriculumTagOptions();
const visualizationSelections = await this.prisma.courseWeekVisualizationPlatform.findMany({
where: {
courseId: course.id,
enabled: true,
},
include: {
platform: true,
},
});
const visualizationSelectionsByWeek = new Map<number, typeof visualizationSelections>();
visualizationSelections.forEach((selection) => {
const items = visualizationSelectionsByWeek.get(selection.week) ?? [];
items.push(selection);
visualizationSelectionsByWeek.set(selection.week, items);
});
const courseMaps = await this.prisma.courseMap.findMany({
where: { courseId: course.id },
orderBy: { createdAt: 'asc' },
@@ -1505,13 +1486,6 @@ export class InstructorService {
name: profile.name,
config: profile.config,
})),
visualizationPlatforms: (visualizationSelectionsByWeek.get(week.week) ?? []).map((selection) => ({
key: selection.platform.key,
type: selection.platform.type,
displayName: selection.platform.displayName,
description: selection.platform.description,
config: selection.platform.defaultConfig,
})),
mapKeys: mapKeysByWeek.get(week.week) ?? [],
};
});
@@ -1546,13 +1520,6 @@ export class InstructorService {
},
isTeamProject: override.isTeamProject ?? false,
modules: [],
visualizationPlatforms: (visualizationSelectionsByWeek.get(override.week) ?? []).map((selection) => ({
key: selection.platform.key,
type: selection.platform.type,
displayName: selection.platform.displayName,
description: selection.platform.description,
config: selection.platform.defaultConfig,
})),
mapKeys: mapKeysByWeek.get(override.week) ?? [],
};
});
@@ -1567,13 +1534,6 @@ export class InstructorService {
},
weeks: [...baseWeeks, ...addedWeeks].sort((left, right) => left.week - right.week),
tagOptions,
visualizationPlatforms: visualizationPlatforms.map((platform) => ({
key: platform.key,
type: platform.type,
displayName: platform.displayName,
description: platform.description,
config: platform.defaultConfig,
})),
mapOptions: [
...NAV2_SYSTEM_MAPS,
...courseMaps.map((map) => ({
@@ -1710,15 +1670,6 @@ export class InstructorService {
});
return items;
}, []);
const selections = await this.prisma.courseWeekVisualizationPlatform.findMany({
where: {
courseId: course.id,
week: input.activeWeek,
enabled: true,
},
include: { platform: true },
});
const selectionsByPlatformKey = new Map(selections.map((selection) => [selection.platformKey, selection]));
const profiles = await this.prisma.courseEnvironmentProfile.findMany({
where: { courseId: course.id, week: input.activeWeek },
});
@@ -1732,33 +1683,22 @@ export class InstructorService {
&& (profile.config as Prisma.JsonObject).target === 'remote-jetson')
);
const wantsPlatform = logicalEnvironment === 'platform';
const selection = isLogicalEnvironment
? selections.find((candidate) => wantsPlatform === isPlatformProfile({
profileType: candidate.platform.type,
config: candidate.platform.defaultConfig,
}))
: selectionsByPlatformKey.get(item.platformKey);
const existingProfile = isLogicalEnvironment
? profiles.find((profile) => wantsPlatform === isPlatformProfile(profile))
: profilesByPlatformKey.get(item.platformKey);
if (!isLogicalEnvironment && !selection && !existingProfile) {
if (!isLogicalEnvironment && !existingProfile) {
throw new BadRequestException('선택한 환경 프로필을 찾을 수 없습니다.');
}
const resolvedPlatformKey = existingProfile?.platformKey
?? selection?.platformKey
?? (wantsPlatform ? 'futuredrive-platform' : 'futuredrive-local-pc');
const profileType = existingProfile?.profileType
?? selection?.platform.type
?? (wantsPlatform ? 'PLATFORM' : 'LOCAL');
const profileName = existingProfile?.name
?? selection?.platform.displayName
?? (wantsPlatform ? '플랫폼' : '로컬');
const existingConfig = existingProfile?.config && typeof existingProfile.config === 'object' && !Array.isArray(existingProfile.config)
? existingProfile.config as Prisma.JsonObject
: {};
const defaultConfig = selection?.platform.defaultConfig && typeof selection.platform.defaultConfig === 'object' && !Array.isArray(selection.platform.defaultConfig)
? selection.platform.defaultConfig as Prisma.JsonObject
: wantsPlatform ? { target: 'remote-jetson' } : { target: 'local' };
const defaultConfig = wantsPlatform ? { target: 'remote-jetson' } : { target: 'local' };
const config = {
...defaultConfig,
...existingConfig,
@@ -1855,49 +1795,6 @@ export class InstructorService {
});
}
if (input.visualizationPlatformKeys !== undefined) {
const selectedKeys = Array.from(new Set(input.visualizationPlatformKeys.map((key) => key.trim().toUpperCase()).filter(Boolean)));
const validPlatforms = selectedKeys.length
? await this.prisma.visualizationPlatform.findMany({
where: {
key: { in: selectedKeys },
enabled: true,
},
select: { key: true },
})
: [];
const validKeySet = new Set(validPlatforms.map((platform) => platform.key));
await this.prisma.courseWeekVisualizationPlatform.deleteMany({
where: {
courseId: course.id,
week: input.activeWeek,
platformKey: { notIn: selectedKeys },
},
});
await Promise.all(selectedKeys.filter((key) => validKeySet.has(key)).map((key) => (
this.prisma.courseWeekVisualizationPlatform.upsert({
where: {
courseId_week_platformKey: {
courseId: course.id,
week: input.activeWeek,
platformKey: key,
},
},
create: {
courseId: course.id,
week: input.activeWeek,
platformKey: key,
enabled: true,
},
update: {
enabled: true,
},
})
)));
}
if (input.mapKeys !== undefined) {
const selectedKeys = Array.from(new Set(input.mapKeys.map((key) => key.trim()).filter(Boolean)));
const customMaps = selectedKeys.length