Skip to content

Commit 4e498cb

Browse files
committed
add crsID <> dependencyName mapping
1 parent 6f4c4b7 commit 4e498cb

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

packages/db/src/impl/static/StaticDataLayerProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export class StaticDataLayerProvider implements DataLayerProvider {
138138
}
139139

140140
getCoursesDB(): CoursesDBInterface {
141-
return new StaticCoursesDB(this.manifests);
141+
return new StaticCoursesDB(this.manifests, this.dependencyNameToCourseId);
142142
}
143143

144144
async getClassroomDB(

packages/db/src/impl/static/coursesDB.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,23 @@ import { StaticCourseManifest } from '../../util/packer/types';
66
import { logger } from '../../util/logger';
77

88
export class StaticCoursesDB implements CoursesDBInterface {
9-
constructor(private manifests: Record<string, StaticCourseManifest>) {}
9+
constructor(
10+
private manifests: Record<string, StaticCourseManifest>,
11+
private dependencyNameToCourseId?: Map<string, string>
12+
) {}
1013

1114
async getCourseConfig(courseId: string): Promise<CourseConfig> {
12-
const manifest = this.manifests[courseId];
15+
// Try direct lookup by courseId first
16+
let manifest = this.manifests[courseId];
17+
18+
// If not found, try lookup by dependency name (backwards compatibility)
19+
if (!manifest && this.dependencyNameToCourseId) {
20+
const mappedCourseId = this.dependencyNameToCourseId.get(courseId);
21+
if (mappedCourseId) {
22+
manifest = this.manifests[mappedCourseId];
23+
}
24+
}
25+
1326
if (!manifest) {
1427
logger.warn(`Course manifest for ${courseId} not found`);
1528
throw new Error(`Course ${courseId} not found`);

0 commit comments

Comments
 (0)