Skip to content

Commit 2aa3ef6

Browse files
committed
Merge remote-tracking branch 'origin/master' into solutions
2 parents 7740701 + a22e73d commit 2aa3ef6

File tree

4 files changed

+27
-15
lines changed

4 files changed

+27
-15
lines changed

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ In the `goals` table, `score0` and `score1` are `NULL`, our intern forgot to wri
110110

111111
### Other resources
112112

113-
- [https://mystery.knightlab.com/](SQL Murder Mystery) - Can you find out whodunnit?
114-
- [https://datalemur.com/](datalemur.com) - Ace the SQL & Data Science Interview
115-
- [https://www.sql-practice.com/](sql-practice.com)
116-
- [https://sqlzoo.net/wiki/SQL_Tutorial](sqlzoo) - Learn SQL in stages (Countries & Teacher datasets came from this one!)
117-
113+
- [SQL Murder Mystery](https://mystery.knightlab.com/) - Can you find out whodunnit?
114+
- [datalemur.com](https://datalemur.com/) - Ace the SQL & Data Science Interview
115+
- [sql-practice.com](https://www.sql-practice.com/)
116+
- [sqlzoo](https://sqlzoo.net/wiki/SQL_Tutorial) - Learn SQL in stages (Countries & Teacher datasets came from this one!)

sql-front/src/exercises/worldcupExercises.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ JOIN rounds r ON m.round_id=r.id JOIN events e ON r.event_id=e.id`,
2020
},
2121
{
2222
id: 2,
23-
desc: 'Which country has "scored" the most ungoals?',
23+
desc: 'Which country has "scored" the most owngoals?',
2424
points: 4,
2525
expected: [
2626
['France', 4]

sql-front/src/leaderboard/ScoreTable.tsx

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ export function ScoreTable({scores}: {scores: Score[]}) {
2727
const fastestTable = calculateFastest(exercises, scores);
2828
const leanestTable = calculateShortest(exercises, scores);
2929

30+
const totalScores = Object.entries(playerScores).map(([player, score]) => {
31+
const fastest = fastestTable.filter(fast => fast.player === player).length;
32+
const shortest = leanestTable.filter(fast => fast.player === player).length;
33+
return {
34+
name: player,
35+
score,
36+
fastest,
37+
shortest,
38+
total: score + fastest * 2 + shortest * 2
39+
};
40+
})
41+
3042
return (
3143
<Table bordered hover>
3244
<thead>
@@ -40,17 +52,15 @@ export function ScoreTable({scores}: {scores: Score[]}) {
4052
</tr>
4153
</thead>
4254
<tbody>
43-
{Object.entries(playerScores).sort((a, b) => b[1] - a[1]).map(([player, score], index) => {
44-
const fastest = fastestTable.filter(fast => fast.player === player).length;
45-
const shortest = leanestTable.filter(fast => fast.player === player).length;
55+
{totalScores.sort((a, b) => b.total - a.total).map((player, index) => {
4656
return (
47-
<tr key={player} className={player === registeredName ? 'table-primary' : undefined}>
57+
<tr key={player.name} className={player.name === registeredName ? 'table-primary' : undefined}>
4858
<td>{index + 1}</td>
49-
<td>{player}</td>
50-
<td>{score}</td>
51-
<td>{fastest}</td>
52-
<td>{shortest}</td>
53-
<td><b>{score + fastest * 2 + shortest * 2}</b></td>
59+
<td>{player.name}</td>
60+
<td>{player.score}</td>
61+
<td>{player.fastest}</td>
62+
<td>{player.shortest}</td>
63+
<td><b>{player.total}</b></td>
5464
</tr>
5565
);
5666
})}

sql-server/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ ENV MSSQL_PID Express
99

1010
EXPOSE 1433
1111

12+
RUN chmod +x ./entrypoint.sh
13+
RUN chmod +x ./run-initialization.sh
14+
1215
CMD /bin/bash ./entrypoint.sh

0 commit comments

Comments
 (0)