Skip to content

Commit ad543f8

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/Lesson_12' into Lesson_12
2 parents 14e7a2b + a50a4ee commit ad543f8

31 files changed

+7002
-3
lines changed
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 17
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: '17'
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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ on:
1515
- "lesson_11/arrays_ts/**"
1616
- "lesson_12/structs_java/**"
1717
- "lesson_12/structs_ts/**"
18+
- "lesson_13/maps_java/**"
19+
- "lesson_13/maps_ts/**"
1820

1921
jobs:
2022
build:
@@ -105,3 +107,13 @@ jobs:
105107
run: |
106108
npm ci
107109
npm run compile
110+
111+
- name: Build Lesson 13 with Java
112+
working-directory: ./lesson_13/maps_java
113+
run: ./gradlew assemble
114+
115+
- name: Build Lesson 13 with Node.js
116+
working-directory: ./lesson_13/maps_ts
117+
run: |
118+
npm ci
119+
npm run compile

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ import { JamesCapparellLoader } from './james_capparell_loader.js';
1111
import { JosephCaballeroLoader } from './joseph_caballero_loader.js';
1212
import { KimberleeHaldaneLoader } from './kimberlee_haldane_loader.js';
1313
import { NileJacksonLoader } from './nile_jackson_loader.js';
14+
import { OyeyemiJimohLoader } from './oyeyemi_jimoh_loader.js';
1415
import { PabloLimonParedesLoader } from './pablo_limon_paredes_loader.js';
16+
import { ShawnDunsmoreLoader } from './shawn_dunsmore_loader.js';
1517
import { TommyTranLoader } from './tommy_tran_loader.js';
1618
import { XavierCruzLoader } from './xavier_cruz_loader.js';
19+
import { YafiahAbdullahLoader } from './yafiah_abdullah_loader.js';
1720
import { ZionBuchananLoader } from './zion_buchanan_loader.js';
1821

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

21-
// Add your quiz provider here.
22-
2324
const LOADER_PROVIDERS = [
2425
AmiyahJonesLoader,
2526
AngelicaCastilloLoader,
@@ -32,9 +33,12 @@ const LOADER_PROVIDERS = [
3233
JosephCaballeroLoader,
3334
KimberleeHaldaneLoader,
3435
NileJacksonLoader,
36+
OyeyemiJimohLoader,
3537
PabloLimonParedesLoader,
38+
ShawnDunsmoreLoader,
3639
TommyTranLoader,
3740
XavierCruzLoader,
41+
YafiahAbdullahLoader,
3842
ZionBuchananLoader,
3943
];
4044

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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 OyeyemiJimohLoader implements Loader {
7+
getLoaderName(): string {
8+
return 'oyeyemijimoh';
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+
const mediaItems = [];
24+
const readable = fs
25+
.createReadStream('data/media_items.csv', 'utf-8')
26+
.pipe(csv());
27+
for await (const row of readable) {
28+
const { id, type, title, year } = row;
29+
mediaItems.push(new MediaItem(id, title, type, year, []));
30+
}
31+
return mediaItems;
32+
}
33+
34+
async loadCredits(): Promise<Credit[]> {
35+
const credits = [];
36+
const readable = fs
37+
.createReadStream('data/credits.csv', 'utf-8')
38+
.pipe(csv());
39+
for await (const row of readable) {
40+
const { media_item_id, role, name } = row;
41+
credits.push(new Credit(media_item_id, name, role));
42+
}
43+
return credits;
44+
}
45+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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 ShawnDunsmoreLoader implements Loader {
7+
getLoaderName(): string {
8+
return 'shawndunsmore';
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+
const mediaItems: MediaItem[] = [];
24+
const readable = fs
25+
.createReadStream('data/media_items.csv', 'utf-8')
26+
.pipe(csv());
27+
28+
for await (const row of readable) {
29+
const { id, title, type, year } = row;
30+
mediaItems.push(new MediaItem(id, title, type, year, []));
31+
}
32+
33+
return mediaItems;
34+
}
35+
36+
async loadCredits(): Promise<Credit[]> {
37+
const credits = [];
38+
const readable = fs
39+
.createReadStream('data/credits.csv', 'utf-8')
40+
.pipe(csv());
41+
for await (const row of readable) {
42+
const { media_item_id, role, name } = row;
43+
credits.push(new Credit(media_item_id, name, role));
44+
}
45+
return credits;
46+
}
47+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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 YafiahAbdullahLoader implements Loader {
7+
getLoaderName(): string {
8+
return 'yafiahabdullah';
9+
}
10+
11+
async loadData(): Promise<MediaItem[]> {
12+
const [credits, mediaItems] = await Promise.all([
13+
this.loadCredits(),
14+
this.loadMediaItems(),
15+
]);
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+
const media = [];
26+
const readable = fs
27+
.createReadStream('data/media_items.csv', 'utf-8')
28+
.pipe(csv());
29+
for await (const row of readable) {
30+
const { id, type, title, year } = row;
31+
media.push(new MediaItem(id, title, type, year, []));
32+
}
33+
return media;
34+
}
35+
36+
async loadCredits(): Promise<Credit[]> {
37+
const credits = [];
38+
const readable = fs
39+
.createReadStream('data/credits.csv', 'utf-8')
40+
.pipe(csv());
41+
for await (const row of readable) {
42+
const { media_item_id, role, name } = row;
43+
credits.push(new Credit(media_item_id, name, role));
44+
}
45+
return credits;
46+
}
47+
}

lesson_13/README.md

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

1010
## Homework
1111

12-
TODO(anthonydmays): Implement this
12+
- [ ] Implement the `findPermutationDifference` method in [Lesson13.java](./maps_java/maps_app/src/main/java/com/codedifferently/lesson13/Lesson13.java).
13+
- [ ] Do pre-work for [lesson 14](/lesson_14/).
14+
15+
## Extra Credit
16+
17+
- [ ] Implement the TypeScript version in [lesson13.ts](./maps_ts/src/lesson13.ts).

lesson_13/maps_java/.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# Linux start script should use lf
5+
/gradlew text eol=lf
6+
7+
# These are Windows script files and should use crlf
8+
*.bat text eol=crlf
9+

lesson_13/maps_java/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Ignore Gradle project-specific cache directory
2+
.gradle
3+
4+
# Ignore Gradle build output directory
5+
build

0 commit comments

Comments
 (0)