Skip to content

Commit 86f149c

Browse files
authored
Merge branch 'code-differently:main' into Work10
2 parents 8f598f1 + 7b3bd25 commit 86f149c

File tree

30 files changed

+7042
-2
lines changed

30 files changed

+7042
-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

.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 { DavisDLoader } from './davis_d_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
DavisDLoader,
1415
MercedesMathewsLoader,
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
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
plugins {
2+
// Apply the application plugin to add support for building a CLI application in Java.
3+
application
4+
eclipse
5+
id("com.diffplug.spotless") version "6.25.0"
6+
id("org.springframework.boot") version "3.4.0"
7+
id("com.adarshr.test-logger") version "4.0.0"
8+
}
9+
10+
apply(plugin = "io.spring.dependency-management")
11+
12+
repositories {
13+
// Use Maven Central for resolving dependencies.
14+
mavenCentral()
15+
}
16+
17+
dependencies {
18+
// Use JUnit Jupiter for testing.
19+
testImplementation("com.codedifferently.instructional:instructional-lib")
20+
testImplementation("org.junit.jupiter:junit-jupiter:5.11.3")
21+
testImplementation("org.springframework.boot:spring-boot-starter-test")
22+
testImplementation("org.assertj:assertj-core:3.26.3")
23+
testImplementation("at.favre.lib:bcrypt:0.10.2")
24+
25+
// This dependency is used by the application.
26+
implementation("com.codedifferently.instructional:instructional-lib")
27+
implementation("com.google.guava:guava:33.3.1-jre")
28+
implementation("com.google.code.gson:gson:2.11.0")
29+
implementation("org.projectlombok:lombok:1.18.30")
30+
implementation("org.springframework.boot:spring-boot-starter")
31+
}
32+
33+
application {
34+
// Define the main class for the application.
35+
mainClass.set("com.codedifferently.lesson11.Lesson11")
36+
}
37+
38+
tasks.named<Test>("test") {
39+
// Use JUnit Platform for unit tests.
40+
useJUnitPlatform()
41+
}
42+
43+
44+
configure<com.diffplug.gradle.spotless.SpotlessExtension> {
45+
46+
format("misc", {
47+
// define the files to apply `misc` to
48+
target("*.gradle", ".gitattributes", ".gitignore")
49+
50+
// define the steps to apply to those files
51+
trimTrailingWhitespace()
52+
indentWithTabs() // or spaces. Takes an integer argument if you don't like 4
53+
endWithNewline()
54+
})
55+
56+
java {
57+
// don't need to set target, it is inferred from java
58+
59+
// apply a specific flavor of google-java-format
60+
googleJavaFormat()
61+
// fix formatting of type annotations
62+
formatAnnotations()
63+
}
64+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.codedifferently.lesson11;
2+
3+
import java.util.List;
4+
5+
public class Lesson11 {
6+
7+
/**
8+
* Provide the solution to LeetCode 1929 here:
9+
* https://leetcode.com/problems/concatenation-of-array
10+
*/
11+
public int[] getConcatenation(int[] nums) {
12+
return null;
13+
}
14+
15+
/**
16+
* Provide the solution to LeetCode 2942 here:
17+
* https://leetcode.com/problems/find-words-containing-character/
18+
*/
19+
public List<Integer> findWordsContaining(String[] words, char x) {
20+
return null;
21+
}
22+
}

0 commit comments

Comments
 (0)