Use pointer receiver more offen

This commit is contained in:
nemunaire 2021-11-22 15:35:07 +01:00
parent 6999b4e728
commit c7569b5e54
59 changed files with 688 additions and 672 deletions

View file

@ -47,7 +47,7 @@ func rankQuery(whereTeam string) string {
) A ` + whereTeam + ` GROUP BY A.id_team ORDER BY score DESC, time ASC`
}
func (t Team) ScoreGrid() (grid []map[string]interface{}, err error) {
func (t *Team) ScoreGrid() (grid []map[string]interface{}, err error) {
q := "SELECT G.reason, G.id_exercice, G.time, G.points, G.coeff FROM (" + teamptsQuery() + ") AS G WHERE G.id_team = ? AND G.points != 0"
if rows, err := DBQuery(q, t.Id); err != nil {
return nil, err
@ -80,7 +80,7 @@ func (t Team) ScoreGrid() (grid []map[string]interface{}, err error) {
// Points
// EstimateGain calculates the amount of point the Team has (or could have, if not already solved) won.
func (e Exercice) EstimateGain(t Team, solved bool) (float64, error) {
func (e *Exercice) EstimateGain(t *Team, solved bool) (float64, error) {
var pts float64
err := DBQueryRow("SELECT SUM(A.points * A.coeff) AS score FROM ("+exoptsQuery("WHERE S.id_team = ? AND S.id_exercice = ?")+") A GROUP BY id_team", t.Id, e.Id, t.Id, e.Id).Scan(&pts)
if solved {
@ -95,7 +95,7 @@ func (e Exercice) EstimateGain(t Team, solved bool) (float64, error) {
}
// GetPoints returns the score for the Team.
func (t Team) GetPoints() (float64, error) {
func (t *Team) GetPoints() (float64, error) {
var tid *int64
var nb *float64
var tzzz *time.Time