Skip to content

Commit 4926e81

Browse files
authored
Merge branch 'main' into feat-RMiller_lesson_10_homework
2 parents 4c1c45f + 4fe012e commit 4926e81

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+14078
-2
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Check Lesson 12 Pull Request
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
paths:
7+
- "lesson_12/structs_java/**"
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up JDK
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: '21'
23+
distribution: 'temurin'
24+
25+
- name: Build Lesson 12 with Java
26+
working-directory: ./lesson_12/structs_java
27+
run: ./gradlew check
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Check Lesson 12 Pull Request
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
paths:
7+
- "lesson_12/structs_ts/**"
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Use Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '20.x'
23+
24+
- name: Build Lesson 12 with Node.js
25+
working-directory: ./lesson_12/structs_ts
26+
run: |
27+
npm ci
28+
npm run check
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Check Lesson 13 Java Pull Request
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
paths:
7+
- "lesson_13/maps_java/**"
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up JDK
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: '21'
23+
distribution: 'temurin'
24+
25+
- name: Build Lesson 13 with Java
26+
working-directory: ./lesson_13/maps_java
27+
run: ./gradlew check
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Check Lesson 13 TS Pull Request
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
paths:
7+
- "lesson_13/maps_ts/**"
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Use Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '20.x'
23+
24+
- name: Build Lesson 13 with Node.js
25+
working-directory: ./lesson_13/maps_ts
26+
run: |
27+
npm ci
28+
npm run check

.github/workflows/check_push.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ on:
1515
- "lesson_10/libraries/**"
1616
- "lesson_11/arrays_java/**"
1717
- "lesson_11/arrays_ts/**"
18+
- "lesson_12/structs_java/**"
19+
- "lesson_12/structs_ts/**"
20+
- "lesson_13/maps_java/**"
21+
- "lesson_13/maps_ts/**"
1822
jobs:
1923
build:
2024
runs-on: ubuntu-latest
@@ -117,3 +121,23 @@ jobs:
117121
run: |
118122
npm ci
119123
npm run compile
124+
125+
- name: Build Lesson 12 with Java
126+
working-directory: ./lesson_12/structs_java
127+
run: ./gradlew assemble
128+
129+
- name: Build Lesson 12 with Node.js
130+
working-directory: ./lesson_12/structs_ts
131+
run: |
132+
npm ci
133+
npm run compile
134+
135+
- name: Build Lesson 13 with Java
136+
working-directory: ./lesson_13/maps_java
137+
run: ./gradlew assemble
138+
139+
- name: Build Lesson 13 with Node.js
140+
working-directory: ./lesson_13/maps_ts
141+
run: |
142+
npm ci
143+
npm run compile
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import csv from 'csv-parser';
2+
import fs from 'fs';
3+
import { Credit, MediaItem } from '../models/index.js';
4+
import { Loader } from './loader.js';
5+
6+
export class ChanelHuttLoader implements Loader {
7+
getLoaderName(): string {
8+
return 'chanelhutt';
9+
}
10+
11+
async loadData(): Promise<MediaItem[]> {
12+
const credits = await this.loadCredits();
13+
const mediaItems = await this.loadMediaItems();
14+
// Create a Hashmap to where the key is a string(MediaItem ID) and the value is the MediaItem object.
15+
const hashMapIndex = new Map<string, MediaItem>();
16+
// Loops through the mediaItems and adds them to the map by their ID.
17+
for (const mediaItem of mediaItems) {
18+
hashMapIndex.set(mediaItem.getId(), mediaItem);
19+
}
20+
// Loops through the credits and adds them to the mediaItem by getting the mediaItem ID.
21+
for (const credit of credits) {
22+
const mediaItem = hashMapIndex.get(credit.getMediaItemId());
23+
if (mediaItem) {
24+
mediaItem.addCredit(credit);
25+
}
26+
console.log(
27+
`Loaded ${credits.length} credits and ${mediaItems.length} media items`,
28+
);
29+
}
30+
// Returns an array of the values from the hashmap.
31+
return Array.from(hashMapIndex.values());
32+
}
33+
34+
async loadMediaItems(): Promise<MediaItem[]> {
35+
const mediaItems = [];
36+
const readable = fs
37+
.createReadStream('data/media_items.csv', 'utf-8')
38+
.pipe(csv());
39+
for await (const row of readable) {
40+
const { id, title, type, year } = row;
41+
mediaItems.push(new MediaItem(id, title, type, year, []));
42+
}
43+
return mediaItems;
44+
}
45+
46+
async loadCredits(): Promise<Credit[]> {
47+
const credits = [];
48+
const readable = fs
49+
.createReadStream('data/credits.csv', 'utf-8')
50+
.pipe(csv());
51+
for await (const row of readable) {
52+
const { media_item_id, role, name } = row;
53+
credits.push(new Credit(media_item_id, name, role));
54+
}
55+
return credits;
56+
}
57+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import csv from 'csv-parser';
2+
import fs from 'fs';
3+
import { Credit, MediaItem } from '../models/index.js';
4+
import { Loader } from './loader.js';
5+
6+
export class DavidAdenaikeLoader implements Loader {
7+
getLoaderName(): string {
8+
return 'davidadenaike';
9+
}
10+
11+
async loadData(): Promise<MediaItem[]> {
12+
const credits = await this.loadCredits();
13+
const mediaItems = await this.loadMediaItems();
14+
15+
console.log(
16+
`Loaded ${credits.length} credits and ${mediaItems.length} media items`,
17+
);
18+
19+
return [...mediaItems.values()];
20+
}
21+
22+
async loadMediaItems(): Promise<MediaItem[]> {
23+
// TODO: Implement this method.
24+
const mediaItems = [];
25+
const readable = fs
26+
.createReadStream('data/media_items.csv', 'utf-8')
27+
.pipe(csv());
28+
for await (const row of readable) {
29+
const { id, type, title, year } = row;
30+
mediaItems.push(new MediaItem(id, title, type, year, []));
31+
}
32+
return mediaItems;
33+
}
34+
35+
async loadCredits(): Promise<Credit[]> {
36+
const credits = [];
37+
const readable = fs
38+
.createReadStream('data/credits.csv', 'utf-8')
39+
.pipe(csv());
40+
for await (const row of readable) {
41+
const { media_item_id, role, name } = row;
42+
credits.push(new Credit(media_item_id, name, role));
43+
}
44+
return credits;
45+
}
46+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import csv from 'csv-parser';
2+
import fs from 'fs';
3+
import { Credit, MediaItem } from '../models/index.js';
4+
import { Loader } from './loader.js';
5+
6+
// Do the extra credit tonight as well as prework for tommorow!!
7+
8+
export class DavisDLoader implements Loader {
9+
getLoaderName(): string {
10+
return 'davis';
11+
}
12+
13+
async loadData(): Promise<MediaItem[]> {
14+
const credits = await this.loadCredits();
15+
const mediaItems = await this.loadMediaItems();
16+
17+
console.log(
18+
`Loaded ${credits.length} credits and ${mediaItems.length} media items`,
19+
);
20+
21+
return [...mediaItems.values()];
22+
}
23+
24+
async loadMediaItems(): Promise<MediaItem[]> {
25+
// TODO: Implement this method.
26+
const MediaItems = [];
27+
const readable = fs
28+
.createReadStream('data/media_items.csv', 'utf-8')
29+
.pipe(csv());
30+
for await (const row of readable) {
31+
const { id, title, type, year } = row;
32+
MediaItems.push(new MediaItem(id, title, type, year, []));
33+
}
34+
return MediaItems;
35+
}
36+
37+
async loadCredits(): Promise<Credit[]> {
38+
const credits = [];
39+
const readable = fs
40+
.createReadStream('data/credits.csv', 'utf-8')
41+
.pipe(csv());
42+
for await (const row of readable) {
43+
const { media_item_id, role, name } = row;
44+
credits.push(new Credit(media_item_id, name, role));
45+
}
46+
return credits;
47+
}
48+
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
import { Module } from '@nestjs/common';
22
import { AnthonyMaysLoader } from './anthony_mays_loader.js';
3+
import { ChanelHuttLoader } from './chanel_hutt_loader.js';
4+
import { DavidAdenaikeLoader } from './david_adenaike_loader.js';
5+
import { DavisDLoader } from './davis_d_loader.js';
36
import { DylanLaffertysLoader } from './dylan_lafferty_loaders.js';
47
import { MercedesMathewsLoader } from './mercedes_mathews_loader.js';
58
import { RasheedMillerLoader } from './rasheed_miller_loader.js';
69
import { MontezBLoader } from './montez_b_loaders.js';
7-
810
export const Loaders = Symbol.for('Loaders');
911

1012
const LOADER_PROVIDERS = [
1113
AnthonyMaysLoader,
1214
DylanLaffertysLoader,
15+
DavisDLoader,
16+
ChanelHuttLoader,
1317
MercedesMathewsLoader,
1418
RasheedMillerLoader,
19+
DavidAdenaikeLoader,
1520
MontezBLoader
1621
];
1722

lesson_12/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,11 @@ Please review the following resources before lecture:
99

1010
## Homework
1111

12-
- TODO(anthonydmays): Add some stuff
12+
- [ ] Implement the `gameResult` method in [Lesson12.java](./structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Lesson12.java).
13+
- [ ] Implement the `Stack` methods in [Stack.java](./structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Stack.java).
14+
- [ ] Submit solutions via PR.
15+
- [ ] Do pre-work for [lesson 13](/lesson_13/).
16+
17+
### Extra credit
18+
19+
- [ ] Complete TypeScript versions of methods in [lesson11.ts](./structs_ts/src/lesson12.ts) and [stack.ts](./structs_ts/src/stack.ts).

0 commit comments

Comments
 (0)