Skip to content

Commit f3d3365

Browse files
committed
Merge remote-tracking branch 'origin/master' into solutions
2 parents 8d55bd4 + de4f561 commit f3d3365

File tree

15 files changed

+72
-31
lines changed

15 files changed

+72
-31
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.sh text eol=lf

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ GET: http://localhost:8000/game/mode?apiKey=secret&mode=init
9696
9797
Allow people to see all solutions at the endgame:
9898
99-
```
99+
```yaml
100100
GET: http://localhost:8000/game/mode?apiKey=secret&mode=end
101101
```
102102

SQL-Training.pptx

10.1 MB
Binary file not shown.

sql-front/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const config = {
22
api: 'http://localhost:8080',
33
leaderboard: {
4-
api: 'http://localhost:8000'
4+
api: 'http://pongit.synology.me:4001' // TODO: put my local IP here!
55
}
66
}
77

sql-front/src/exercises/Exercise.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export function Exercise({exercise}: {exercise: ExerciseModel}) {
2020
<>
2121
<h1>
2222
{exercise.name}
23+
<ExercisePoints exercise={exercise} />
2324
<ExerciseSchema exercise={exercise} />
2425
</h1>
2526
<p>{exercise.desc}</p>
@@ -308,6 +309,23 @@ function HintTable({sql}: {sql: SqlExerciseModel}) {
308309
}
309310

310311

312+
function ExercisePoints({exercise}: {exercise: ExerciseModel}) {
313+
const totalPoints = exercise.exercises.reduce((pts, ex) => ex.points + pts, 0);
314+
315+
return (
316+
<small>
317+
<Badge bg="primary" style={{fontSize: 14, marginLeft: 8}} title="Exercise count">
318+
#{exercise.exercises.length}
319+
</Badge>
320+
<Badge bg="primary" style={{fontSize: 14, marginLeft: 8}}>
321+
{totalPoints} points
322+
</Badge>
323+
</small>
324+
)
325+
}
326+
327+
328+
311329
function ExerciseSchema({exercise}: {exercise: ExerciseModel}) {
312330
const [show, setShow] = useState(false);
313331

sql-front/src/exercises/ExerciseSampleData.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ function TableBody({data}: {data: any[]}) {
5656
}
5757

5858
function Cell({value}: {value: any}) {
59+
if (typeof value === 'boolean')
60+
return <td>{value.toString()}</td>
61+
5962
if (value === null)
6063
return <td><i>NULL</i></td>
6164

@@ -65,8 +68,10 @@ function Cell({value}: {value: any}) {
6568
if (typeof value === 'string' && value.indexOf('-') !== -1 && value.indexOf('-') !== value.lastIndexOf('-'))
6669
return <td>{value}</td>
6770

68-
if (!isNaN(parseInt(value)) && value[value.length - 1] !== '%')
69-
return <td style={{textAlign: 'right'}}>{(+value).toLocaleString().replace(/,/g, '.')}</td>
71+
if (!isNaN(parseInt(value)) && value[value.length - 1] !== '%') {
72+
const belgianFormattedValue = (+value).toLocaleString("nl-BE")
73+
return <td style={{textAlign: 'right'}}>{belgianFormattedValue}</td>
74+
}
7075

7176
return <td>{value}</td>
7277
}

sql-front/src/exercises/worldExercises.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const worldExercises: ExerciseModel = {
88
exercises: [
99
{
1010
id: 1,
11-
desc: 'Give the name and the per capita GDP (without decimals) for all countries with a population of at least 200 million.',
11+
desc: 'Give the name and the floored per capita GDP for all countries with a population of at least 200 million.',
1212
points: 1,
1313
expected: [
1414
['Brazil', 11115],
@@ -85,16 +85,16 @@ export const worldExercises: ExerciseModel = {
8585
desc: 'List the continents with the amount of countries in it, the country with the smallest area and its name, the total population and the rounded average gdp per capita.',
8686
points: 3,
8787
expected: [
88-
['Africa', 53, 452, 'Seychelles', 1016091005, 2687],
89-
['Asia', 46, 300, 'Maldives', 4317455576, 12988],
90-
['Caribbean', 11, 344, 'Grenada', 36149204, 10049],
91-
['Eurasia', 2, 29743, 'Armenia', 149017400, 8600],
92-
['Europe', 44, 0, 'Vatican City', 610261850, 34405],
93-
['North America', 11, 261, 'Saint Kitts and Nevis', 518755156, 14104],
94-
['Oceania', 14, 21, 'Nauru', 37783477, 11284],
95-
['South America', 13, 389, 'Saint Vincent and the Grenadines', 407618970, 8594],
88+
['Africa', 53, 452, 'Seychelles', 1016091005, 1783],
89+
['Asia', 46, 300, 'Maldives', 4317455576, 5571],
90+
['Caribbean', 11, 344, 'Grenada', 36149204, 5297],
91+
['Eurasia', 2, 29743, 'Armenia', 149017400, 13688],
92+
['Europe', 44, 0, 'Vatican City', 610261850, 30060],
93+
['North America', 11, 261, 'Saint Kitts and Nevis', 518755156, 37012],
94+
['Oceania', 14, 21, 'Nauru', 37783477, 46564],
95+
['South America', 13, 389, 'Saint Vincent and the Grenadines', 407618970, 10194],
9696
],
97-
expectedOrder: true,
97+
expectedOrder: false,
9898
expectedColumns: ['continent', 'countries', 'smallest area', 'smallest name', 'total population', 'averga gdp']
9999
},
100100
{

sql-front/src/layout/TopNavigation.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export const fetchData = (key: 'home' | ExerciseId) => async (dispatch: AppDispa
1212
headers: { 'Content-Type': 'application/json' },
1313
});
1414
const data = await res.json();
15-
dispatch({type: 'exercises/setScores', payload: data});
15+
if (!data.message) {
16+
dispatch({type: 'exercises/setScores', payload: data});
17+
}
1618
} catch (error) {
1719
console.error('Could not fetch leaderboard', error);
1820
}

sql-leaderboard/Dockerfile

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
11
FROM node:22.9.0-slim
22

3-
# Create app directory
43
WORKDIR /usr/src/app
5-
6-
# Copy package.json and package-lock.json
74
COPY package*.json ./
8-
9-
# Install app dependencies
105
RUN npm ci
11-
12-
# Bundle app source
136
COPY . .
14-
15-
# Build the TypeScript files
167
RUN npm run build
17-
18-
# Expose port 8080
19-
EXPOSE 8080
20-
21-
# Start the app
8+
EXPOSE 8000
229
CMD npm run start
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
version: '3.8'
22

33
services:
4+
back-end:
5+
build:
6+
context: ./
7+
dockerfile: Dockerfile
8+
restart: always
9+
ports:
10+
- 4001:8000
11+
networks:
12+
- leadernet
13+
414
postgres:
515
image: postgres:17.0
616
environment:
@@ -14,6 +24,12 @@ services:
1424
ports:
1525
- "${PG_PORT}:5432"
1626
restart: always
27+
networks:
28+
- leadernet
1729

1830
volumes:
1931
postgres:
32+
33+
networks:
34+
leadernet:
35+
driver: bridge

0 commit comments

Comments
 (0)