mirror of
https://github.com/gojp/goreportcard.git
synced 2026-01-29 06:49:05 +08:00
add 1 to index for high score rank
This commit is contained in:
@@ -9,6 +9,10 @@ import (
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
)
|
||||
|
||||
func add(x, y int) int {
|
||||
return x + y
|
||||
}
|
||||
|
||||
var highScores []struct {
|
||||
Repo string
|
||||
Files int
|
||||
@@ -31,12 +35,8 @@ func HighScoresHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
t, err := template.New("high_scores.html").ParseFiles("templates/high_scores.html")
|
||||
if err != nil {
|
||||
log.Println("ERROR: ", err)
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
funcs := template.FuncMap{"add": add}
|
||||
t := template.Must(template.New("high_scores.html").Funcs(funcs).ParseFiles("templates/high_scores.html"))
|
||||
|
||||
t.Execute(w, map[string]interface{}{"HighScores": highScores})
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
<tbody>
|
||||
{{ range $index, $highScore := .HighScores }}
|
||||
<tr>
|
||||
<td>{{ $index }}</td>
|
||||
<td>{{ add $index 1 }}</td>
|
||||
<td><a href="https://github.com/{{ $highScore.Repo }}" rel="nofollow">{{ $highScore.Repo }}</a></td>
|
||||
<td>{{ $highScore.Files }}</td>
|
||||
<td>{{ $highScore.Average }}</td>
|
||||
|
||||
Reference in New Issue
Block a user