Skip to content

Commit

Permalink
Some minor UI fixes and improvments
Browse files Browse the repository at this point in the history
  • Loading branch information
thordy committed Sep 24, 2017
1 parent d3efbea commit 8eb14e5
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 31 deletions.
2 changes: 1 addition & 1 deletion controller/match_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ function getPlayerStatistics(players, scores, startingScore) {
// Set accuracy stats for each players
var accuracyStats = player.accuracyStats;
if ((accuracyStats.attempts20 + accuracyStats.attempts19 + accuracyStats.misses) == 0) {
accuracyStats.overallAccuracy = 0;
accuracyStats.overallAccuracy = null; // No stats available
} else {
accuracyStats.overallAccuracy = (accuracyStats.accuracy20 + accuracyStats.accuracy19) /
(accuracyStats.attempts20 + accuracyStats.attempts19 + accuracyStats.misses);
Expand Down
1 change: 1 addition & 0 deletions controller/statistics_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function getStatistics(from, to, callback) {
p.id as 'player_id',
p.name AS 'player_name',
COUNT(DISTINCT g.id) AS 'games_played',
0 as 'games_won', -- This will be updated in the next query
SUM(s.ppd) / COUNT(p.id) AS 'ppd',
SUM(s.first_nine_ppd) / COUNT(p.id) AS 'first_nine_ppd',
SUM(60s_plus) AS '60s_plus',
Expand Down
8 changes: 1 addition & 7 deletions public/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,7 @@ a:hover {
}

/* CSS Related to player statistics page */
#player_statistics_table td {
text-align: center;
}
#player_accuracy_table td {
text-align: center;
}
#player_scores_table td {
#player_statistics_table td, #player_accuracy_table td, #player_scores_table td, #player_highscores_table td {
text-align: center;
}
#player_scores_table label {
Expand Down
35 changes: 22 additions & 13 deletions views/player_statistics.pug
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ block content
th First 9 PPD
th Overall PPD
th Checkout%
th Scores
tbody
tr
td
Expand All @@ -58,14 +57,25 @@ block content
td
p= player.ppd.toFixed(2)
td
p= (player.gamesWon * 100 / (player.checkoutAttempts === undefined ? 0 : player.checkoutAttempts)).toFixed(2) + '%'
td
p= player['60+'] == 0 ? "" : "60+: " + player['60+']
p= player['100+'] == 0 ? "" : "100+: " + player['100+']
p= player['140+'] == 0 ? "" : "140+: " + player['140+']
p= player['180s'] == 0 ? "" : "180: " + player['180s']

div(class='table-responsive')
if player.gamesWon === 0
p -
else
p= (player.gamesWon * 100 / (player.checkoutAttempts === null ? 0 : player.checkoutAttempts)).toFixed(2) + '%'
h3 High Scores
table(id='player_highscores_table' class='table table-striped table-bordered')
thead
tr
th 60+
th 100+
th 140+
th 180
tbody
tr
td: p= player['60+']
td: p= player['100+']
td: p= player['140+']
td: p= player['180s']
h3 Accuracy
table(id='player_accuracy_table' class='table table-striped table-bordered')
thead
tr
Expand All @@ -79,10 +89,9 @@ block content
td
p= player.accuracy_20 === null ? 'Not Available' : player.accuracy_20.toFixed(2)
td
p= player.accuracy_19 === null ? 'Not Available' : player.accuracy_19.toFixed(2)
p= player.accuracy_19 === null ? 'Not Available' : player.accuracy_19.toFixed(2)

div(class='table-responsive')
h2 Hits
h3 Hits
table(id='player_scores_table' class='table table-striped table-bordered')
thead
tr
Expand Down Expand Up @@ -111,7 +120,7 @@ block content
td= value
td= (value * 100 / scoresMap.totalThrows).toFixed(2) + '%'

h2 Heatmap
h3 Heatmap
select(id='heatmap_value_selector' name='dartValues')
option(value=0 default=true) All
option(value=1) Singles
Expand Down
26 changes: 16 additions & 10 deletions views/weekly_overview.pug
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ block content
div(class='table-responsive')
table(class='table table-striped table-bordered')
thead
tr
th(colspan='10')
th(colspan='3') Accuracy
tr
th Rank
th Player
Expand All @@ -21,19 +24,19 @@ block content
th 100s+
th 140s+
th 180
th Accuracy
th Accuracy (20s)
th Accuracy (19s)
th Overall
th 20s
th 19s
tbody
- var rank = 1
each stats in weekly.this_week
tr
td= rank++
td= stats.player_name
td(style='width: 12%')= stats.player_name
td= stats.games_played
td= stats.games_won === undefined ? 0 : stats.games_won
td= stats.ppd.toFixed(2)
td= stats.first_nine_ppd.toFixed(2)
td(style='width: 12%')= stats.first_nine_ppd.toFixed(2)
td= stats['60s_plus']
td= stats['100s_plus']
td= stats['140s_plus']
Expand All @@ -49,6 +52,9 @@ block content
div(class='table-responsive')
table(class='table table-striped table-bordered')
thead
tr
th(colspan='10')
th(colspan='3') Accuracy
tr
th Rank
th Player
Expand All @@ -60,19 +66,19 @@ block content
th 100s+
th 140s+
th 180
th Accuracy
th Accuracy (20s)
th Accuracy (19s)
th Overall
th 20s
th 19s
tbody
- var rank = 1
each stats in weekly.last_week
tr
td= rank++
td= stats.player_name
td(style='width: 12%')= stats.player_name
td= stats.games_played
td= stats.games_won === undefined ? 0 : stats.games_won
td= stats.ppd.toFixed(2)
td= stats.first_nine_ppd.toFixed(2)
td(style='width: 12%')= stats.first_nine_ppd.toFixed(2)
td= stats['60s_plus']
td= stats['100s_plus']
td= stats['140s_plus']
Expand Down

0 comments on commit 8eb14e5

Please sign in to comment.