Skip to content

Feat/Chore: fixing merge conflicts for lesson10 and matching mediaItem and credits #382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 0 additions & 62 deletions lesson_10/libraries/src/loaders/dylan_lafferty_loaders.ts

This file was deleted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you've deleted Dylan's and Khayla's loaders. Please restore theirs.

Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@ import fs from 'fs';
import { Credit, MediaItem } from '../models/index.js';
import { Loader } from './loader.js';

export class MercedesMathewsLoader implements Loader {
export class KhaylaSaundersLoader implements Loader {
getLoaderName(): string {
return 'mercedesmathews';
return 'khaylasaunders';
}

//TA Help/Chatgpt to complete Extra Credit
async loadData(): Promise<MediaItem[]> {
const credits = await this.loadCredits();
const mediaItems = await this.loadMediaItems();

const mediaMap = new Map<string, MediaItem>();
for (const media of mediaItems) {
mediaMap.set(media.getId(), media);
}
const credits = await this.loadCredits();

for (const credit of credits) {
const mediaItem = mediaMap.get(credit.getMediaItemId());
const mediaItem = mediaItems.find(
(item) => item.getId() === credit.getMediaItemId(),
);

if (mediaItem) {
mediaItem.addCredit(credit);
}
Expand All @@ -28,20 +26,20 @@ export class MercedesMathewsLoader implements Loader {
`Loaded ${credits.length} credits and ${mediaItems.length} media items`,
);

console.log(...mediaItems.values());
return [...mediaItems.values()];
return mediaItems;
}

async loadMediaItems(): Promise<MediaItem[]> {
const medias = [];
// TODO: Implement this method.
const mediaItems = [];
const readable = fs
.createReadStream('data/media_items.csv', 'utf-8')
.pipe(csv());
for await (const row of readable) {
const { id, title, type, year } = row;
medias.push(new MediaItem(id, title, type, year, []));
mediaItems.push(new MediaItem(id, title, type, year, []));
}
return medias;
return mediaItems;
}

async loadCredits(): Promise<Credit[]> {
Expand Down
2 changes: 2 additions & 0 deletions lesson_10/libraries/src/loaders/loaders.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { Module } from '@nestjs/common';

import { AnthonyMaysLoader } from './anthony_mays_loader.js';
import { DylanLaffertysLoader } from './dylan_lafferty_loaders.js';
import { KhaylaSaundersLoader } from './khayla_saunders_loader.js';
import { MercedesMathewsLoader } from './mercedes_mathews_loader.js';

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

const LOADER_PROVIDERS = [
AnthonyMaysLoader,
KhaylaSaundersLoader,
DylanLaffertysLoader,
MercedesMathewsLoader,
];
Expand Down
Loading