Skip to content

Commit aa08f7f

Browse files
authored
Merge branch 'main' into Lesson10
2 parents 4e59cc4 + 5c28980 commit aa08f7f

File tree

66 files changed

+14391
-5
lines changed

Some content is hidden

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

66 files changed

+14391
-5
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.codedifferently.lesson9.dataprovider;
2+
3+
import java.util.Map;
4+
import org.springframework.stereotype.Service;
5+
6+
@Service
7+
public class ChanelHuttProvider extends DataProvider {
8+
public String getProviderName() {
9+
return "chanelhutt";
10+
}
11+
12+
public Map<String, Class> getColumnTypeByName() {
13+
return Map.of(
14+
"column1", Double.class,
15+
"column2", Short.class,
16+
"column3", Integer.class,
17+
"column4", String.class,
18+
"column5", Long.class,
19+
"column6", Boolean.class,
20+
"column7", Float.class);
21+
}
22+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
[
2+
{
3+
"column1": "1.731075412920716E308",
4+
"column2": "19176",
5+
"column3": "733205455",
6+
"column4": "haxpw7g",
7+
"column5": "1157940937089738496",
8+
"column6": "false",
9+
"column7": "2.459581E37"
10+
},
11+
{
12+
"column1": "2.2465348083056824E307",
13+
"column2": "21719",
14+
"column3": "1332875183",
15+
"column4": "ev5bksjy7mz3",
16+
"column5": "2433500635024735232",
17+
"column6": "false",
18+
"column7": "1.0160553E38"
19+
},
20+
{
21+
"column1": "9.114475329125451E306",
22+
"column2": "22876",
23+
"column3": "1941625523",
24+
"column4": "0umiwpak",
25+
"column5": "2117973580872942080",
26+
"column6": "false",
27+
"column7": "1.7494759E38"
28+
},
29+
{
30+
"column1": "1.228449265255592E307",
31+
"column2": "21165",
32+
"column3": "1604518885",
33+
"column4": "tnecirkhowg",
34+
"column5": "8671624959944894464",
35+
"column6": "false",
36+
"column7": "3.4007451E38"
37+
},
38+
{
39+
"column1": "3.900189719800849E307",
40+
"column2": "861",
41+
"column3": "133068872",
42+
"column4": "6yt2rpo8egs7",
43+
"column5": "2144446409450103040",
44+
"column6": "true",
45+
"column7": "2.6716434E38"
46+
},
47+
{
48+
"column1": "1.6560886655049307E308",
49+
"column2": "30429",
50+
"column3": "1200814099",
51+
"column4": "slo4b",
52+
"column5": "4165282877190061568",
53+
"column6": "false",
54+
"column7": "1.2459889E38"
55+
},
56+
{
57+
"column1": "2.3503323112186533E307",
58+
"column2": "4738",
59+
"column3": "1211063412",
60+
"column4": "39ghf5n04",
61+
"column5": "8351477286928983040",
62+
"column6": "true",
63+
"column7": "1.5175942E38"
64+
},
65+
{
66+
"column1": "1.0540459020911906E306",
67+
"column2": "5685",
68+
"column3": "1214520000",
69+
"column4": "y65w912l47",
70+
"column5": "6563929531867928576",
71+
"column6": "true",
72+
"column7": "1.7849906E38"
73+
},
74+
{
75+
"column1": "3.686407320819559E307",
76+
"column2": "28996",
77+
"column3": "1411969638",
78+
"column4": "t0jg47n1vz",
79+
"column5": "6811264016170342400",
80+
"column6": "false",
81+
"column7": "3.0525288E38"
82+
},
83+
{
84+
"column1": "7.473392367859956E307",
85+
"column2": "15836",
86+
"column3": "1137183814",
87+
"column4": "95qrap07h",
88+
"column5": "516976948379531328",
89+
"column6": "true",
90+
"column7": "7.8719054E37"
91+
}
92+
]
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: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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 DylanLaffertysLoader implements Loader {
7+
getLoaderName(): string {
8+
return 'dylanlafferty';
9+
}
10+
async loadData(): Promise<MediaItem[]> {
11+
const credits = await this.loadCredits(); //loads credits from the csv file
12+
const mediaItems = await this.loadMediaItems(); //loads media items from csv file
13+
14+
//Creates a map where the key is a string and the value is MediaItem Object
15+
const mapIndex = new Map<string, MediaItem>();
16+
17+
//Loops through the CSV file and gets the id of the mediaItem that is specified.
18+
for (const mediaItem of mediaItems) {
19+
mapIndex.set(mediaItem.getId(), mediaItem);
20+
21+
}
22+
23+
for (const credit of credits) {
24+
const mediaItem = mapIndex.get(credit.getMediaItemId()); //Finds the media item by getting media ID
25+
if (mediaItem) {
26+
mediaItem.addCredit(credit);
27+
}
28+
}
29+
30+
console.log(
31+
`Loaded ${credits.length} credits and ${mediaItems.length} media items`,
32+
);
33+
//Returns a newly created array by converting the map values
34+
return Array.from(mapIndex.values());
35+
}
36+
37+
async loadMediaItems(): Promise<MediaItem[]> {
38+
const mediaItem = [];
39+
const readable = fs
40+
.createReadStream('data/media_items.csv', 'utf-8')
41+
.pipe(csv());
42+
43+
for await (const row of readable) {
44+
const { id, title, type, year } = row;
45+
mediaItem.push(new MediaItem(id, title, type, year, []));
46+
}
47+
return mediaItem;
48+
}
49+
50+
async loadCredits(): Promise<Credit[]> {
51+
const credits = [];
52+
const readable = fs
53+
.createReadStream('data/credits.csv', 'utf-8')
54+
.pipe(csv());
55+
for await (const row of readable) {
56+
const { media_item_id, role, name } = row;
57+
credits.push(new Credit(media_item_id, name, role));
58+
}
59+
return credits;
60+
}
61+
}
62+
//# sourceMappingURL=dylan_lafferty_loaders.js.map

0 commit comments

Comments
 (0)