28 lines
483 B
Go
28 lines
483 B
Go
package web
|
|
|
|
import (
|
|
"net/http"
|
|
"pool-stats/database"
|
|
"pool-stats/models"
|
|
)
|
|
|
|
type TopSharesPageData struct {
|
|
PageDataBase
|
|
|
|
Shares []models.ShareLog
|
|
}
|
|
|
|
func (ws *WebServer) TopSharesHandler(w http.ResponseWriter, r *http.Request) {
|
|
topShares := database.ListTopShares(ws.db)
|
|
if topShares == nil {
|
|
http.Error(w, "Failed to load top shares", 500)
|
|
return
|
|
}
|
|
|
|
data := TopSharesPageData{
|
|
Shares: topShares,
|
|
}
|
|
|
|
ws.renderTemplate(w, r, "templates/top_shares.html", &data)
|
|
}
|