Skip to content

Commit 4885b10

Browse files
committed
task readded work into lesson 10
1 parent 3687a3c commit 4885b10

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

lesson_10/libraries/src/loaders/justin_eklund_loader.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,25 @@ export class JustinEklundLoader implements Loader {
1212
const credits = await this.loadCredits();
1313
const mediaItems = await this.loadMediaItems();
1414
const mediamap = new Map<string, MediaItem>();
15-
mediaItems.forEach((mediaItem) => {
15+
mediaItems.forEach((mediaItem) => {
1616
mediamap.set(mediaItem.getId(), mediaItem);
17-
}); console.log( `Loaded ${credits.length} credits and ${mediaItems.length} media items`,
17+
});
18+
for (const mediaitem of mediaItems) {
19+
mediamap.set(mediaitem.getId(), mediaitem);
20+
}
21+
for (const credit of credits) {
22+
const mediaItem = mediamap.get(credit.getMediaItemId());
23+
24+
if (mediaItem) {
25+
mediaItem.addCredit(credit);
26+
}
27+
}
28+
console.log(
29+
`Loaded ${credits.length} credits and ${mediaItems.length} media items`,
1830
);
31+
1932

20-
return [...mediaItems.values()];
33+
return Array.from(mediamap.values());
2134
}
2235

2336
async loadMediaItems(): Promise<MediaItem[]> {
@@ -44,4 +57,4 @@ export class JustinEklundLoader implements Loader {
4457
return credits;
4558
}
4659
}
47-
// got assistance from ai and copilot aswell as Meiko and Mercedes
60+
// got assistance from ai and copilot aswell as Meiko ,Mercedes and Dillon

lesson_10/libraries/src/loaders/loaders.module.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import { Module } from '@nestjs/common';
2+
import { DylanLaffertysLoader } from './dylan_lafferty_loaders.js';
23

34
import { AnthonyMaysLoader } from './anthony_mays_loader.js';
45
import { JustinEklundLoader } from './justin_eklund_loader.js';
5-
export const Loaders = Symbol.for('Loaders');
66

7-
const LOADER_PROVIDERS = [AnthonyMaysLoader, JustinEklundLoader];
8-
import { DylanLaffertysLoader } from './dylan_lafferty_loaders.js';
97

108
export const Loaders = Symbol.for('Loaders');
119

12-
const LOADER_PROVIDERS = [AnthonyMaysLoader, DylanLaffertysLoader];
10+
const LOADER_PROVIDERS = [AnthonyMaysLoader, DylanLaffertysLoader,JustinEklundLoader];
1311

1412
@Module({
1513
providers: [

0 commit comments

Comments
 (0)