Use pointer receiver more offen
This commit is contained in:
parent
6999b4e728
commit
c7569b5e54
59 changed files with 688 additions and 672 deletions
|
@ -6,7 +6,7 @@ import (
|
|||
)
|
||||
|
||||
// GetHistory aggregates all sources of events or actions for an Exercice
|
||||
func (e Exercice) GetHistory() ([]map[string]interface{}, error) {
|
||||
func (e *Exercice) GetHistory() ([]map[string]interface{}, error) {
|
||||
hist := make([]map[string]interface{}, 0)
|
||||
|
||||
if rows, err := DBQuery(`SELECT id_team, U.name, U.color, "tries" AS kind, time, 0, id_exercice, NULL, NULL FROM exercice_tries NATURAL JOIN teams U WHERE id_exercice = ? UNION
|
||||
|
@ -57,7 +57,7 @@ func (e Exercice) GetHistory() ([]map[string]interface{}, error) {
|
|||
}
|
||||
|
||||
// UpdateHistoryItem sets values an entry from the history.
|
||||
func (e Exercice) UpdateHistoryItem(coeff float32, tId int64, kind string, h time.Time, secondary *int64) (interface{}, error) {
|
||||
func (e *Exercice) UpdateHistoryItem(coeff float32, tId int64, kind string, h time.Time, secondary *int64) (interface{}, error) {
|
||||
if kind == "hint" && secondary != nil {
|
||||
if res, err := DBExec("UPDATE team_hints SET coefficient = ?, time = ? WHERE id_team = ? AND time = ? AND id_hint = ?", coeff, h, tId, h, *secondary); err != nil {
|
||||
return 0, err
|
||||
|
@ -88,7 +88,7 @@ func (e Exercice) UpdateHistoryItem(coeff float32, tId int64, kind string, h tim
|
|||
}
|
||||
|
||||
// DelHistoryItem removes from the database an entry from the history.
|
||||
func (e Exercice) DelHistoryItem(tId int64, kind string, h time.Time, secondary *int64) (interface{}, error) {
|
||||
func (e *Exercice) DelHistoryItem(tId int64, kind string, h time.Time, secondary *int64) (interface{}, error) {
|
||||
if kind == "tries" {
|
||||
if res, err := DBExec("DELETE FROM exercice_tries WHERE id_team = ? AND time = ? AND id_exercice = ?", tId, h, e.Id); err != nil {
|
||||
return 0, err
|
||||
|
|
Reference in a new issue