Skip to content

Commit d624183

Browse files
authored
Merge branch 'main' into release/David.A-lesson10HW
2 parents 73334cd + ac458a6 commit d624183

Some content is hidden

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

61 files changed

+14090
-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 11 Pull Request
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
paths:
7+
- "lesson_11/arrays_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 11 with Java
26+
working-directory: ./lesson_11/arrays_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 11 Pull Request
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
paths:
7+
- "lesson_11/arrays_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 11 with Node.js
25+
working-directory: ./lesson_11/arrays_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 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

.github/workflows/check_push.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
- "lesson_06/quiz/**"
1212
- "lesson_06/expression/**"
1313
- "lesson_07/conditionals/**"
14+
- "lesson_09/types/**"
15+
- "lesson_10/libraries/**"
16+
- "lesson_11/arrays_java/**"
17+
- "lesson_11/arrays_ts/**"
1418
jobs:
1519
build:
1620
runs-on: ubuntu-latest
@@ -103,3 +107,13 @@ jobs:
103107
run: |
104108
npm ci
105109
npm run compile
110+
111+
- name: Build Lesson 11 with Java
112+
working-directory: ./lesson_11/arrays_java
113+
run: ./gradlew assemble
114+
115+
- name: Build Lesson 11 with Node.js
116+
working-directory: ./lesson_11/arrays_ts
117+
run: |
118+
npm ci
119+
npm run compile

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { AnthonyMaysLoader } from './anthony_mays_loader.js';
44
import { DavidAdenaikeLoader } from './david_adenaike_loader.js';
55
import { DylanLaffertysLoader } from './dylan_lafferty_loaders.js';
66
import { MercedesMathewsLoader } from './mercedes_mathews_loader.js';
7+
import { MontezBLoader } from './montez_b_loaders.js';
78

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

@@ -12,6 +13,7 @@ const LOADER_PROVIDERS = [
1213
DylanLaffertysLoader,
1314
MercedesMathewsLoader,
1415
DavidAdenaikeLoader,
16+
MontezBLoader
1517
];
1618

1719
@Module({
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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 MontezBLoader implements Loader {
7+
getLoaderName(): string {
8+
return 'montezb';
9+
}
10+
11+
async loadData(): Promise<MediaItem[]> {
12+
const credits = await this.loadCredits();
13+
const mediaItems = await this.loadMediaItems();
14+
15+
const mediaMap = new Map<string, MediaItem>();
16+
17+
for (const media of mediaItems) {
18+
mediaMap.set(media.getId(), media);
19+
}
20+
21+
for (const credit of credits) {
22+
const mediaItem = mediaMap.get(credit.getMediaItemId());
23+
if (mediaItem) {
24+
mediaItem.addCredit(credit);
25+
}
26+
}
27+
28+
console.log(
29+
`Loaded ${credits.length} credits and ${mediaItems.length} media items`,
30+
);
31+
32+
return Array.from(mediaMap.values());
33+
}
34+
35+
async loadMediaItems(): Promise<MediaItem[]> {
36+
// TODO: Implement this method.
37+
const mediaItems = [];
38+
const readable = fs
39+
.createReadStream('data/media_items.csv', 'utf-8')
40+
.pipe(csv());
41+
42+
for await (const row of readable) {
43+
const { id, title, type, year } = row;
44+
mediaItems.push(new MediaItem( id, title, type, year, []));
45+
}
46+
return mediaItems;
47+
}
48+
49+
async loadCredits(): Promise<Credit[]> {
50+
const credits = [];
51+
const readable = fs
52+
.createReadStream('data/credits.csv', 'utf-8')
53+
.pipe(csv());
54+
for await (const row of readable) {
55+
const { media_item_id, role, name } = row;
56+
credits.push(new Credit(media_item_id, name, role));
57+
}
58+
return credits;
59+
}
60+
}

lesson_11/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): Come up with something
12+
- [ ] Complete methods in [Lesson11.java](./arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java) and submit PR.
13+
- [ ] Do pre-work for [lesson 12](/lesson_12/).
14+
15+
### Extra credit
16+
17+
- [ ] Complete TypeScript version of methods in [Lesson11.ts](./arrays_ts/src/lesson11.ts) and submit PR.

lesson_11/arrays_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_11/arrays_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)