Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
You'll see a short list of NHL teams, their scores, and buttons to increase their scores.
Right now, clicking on a button doesn't increase the score immediately,
but you need to refresh the page to see the change. The goal is to reflect
this change immediately on the front-end. Once that's done, we would also like
to sort the teams so that whenever there's a score change, the list would change
so that the teams are listed in non-increasing order of scores from top to bottom
(you don't need to sort them alphabetically when there is a tie). To do these,
you would need to make changes in both server.py file and scoreboard.js file.
When you're done, please send a pull request to this repository with your name and
uni in the comment. Thanks and good luck!


1. Update scores live on the website
2. Sort the teams in non-increasing order from top to bottom (no tiebreaking necessary for teams with the same score)

3 changes: 3 additions & 0 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ def increase_score():
for team in scoreboard:
if team["id"] == team_id:
team["score"] += 1
break

scoreboard.sort(key = lambda team: team["score"], reverse = True)

return jsonify(scoreboard=scoreboard)

Expand Down
2 changes: 1 addition & 1 deletion static/scoreboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function increase_score(id){
contentType: "application/json; charset=utf-8",
data : JSON.stringify(team_id),
success: function(result){

display_scoreboard(result.scoreboard);
},
error: function(request, status, error){
console.log("Error");
Expand Down