Use pointer receiver more offen
This commit is contained in:
parent
6999b4e728
commit
c7569b5e54
59 changed files with 688 additions and 672 deletions
|
|
@ -5,7 +5,7 @@ import (
|
|||
)
|
||||
|
||||
// GetHistory aggregates all sources of events or actions for a Team
|
||||
func (t Team) GetHistory() ([]map[string]interface{}, error) {
|
||||
func (t *Team) GetHistory() ([]map[string]interface{}, error) {
|
||||
hist := make([]map[string]interface{}, 0)
|
||||
|
||||
if rows, err := DBQuery(`SELECT id_team, "tries" AS kind, time, 0, E.id_exercice, E.title, NULL, NULL FROM exercice_tries T INNER JOIN exercices E ON E.id_exercice = T.id_exercice WHERE id_team = ? UNION
|
||||
|
|
@ -55,7 +55,7 @@ func (t Team) GetHistory() ([]map[string]interface{}, error) {
|
|||
}
|
||||
|
||||
// UpdateHistoryCoeff updates the coefficient for a given entry.
|
||||
func (t Team) UpdateHistoryCoeff(kind string, h time.Time, givenId int64, newCoeff float32) (interface{}, error) {
|
||||
func (t *Team) UpdateHistoryCoeff(kind string, h time.Time, givenId int64, newCoeff float32) (interface{}, error) {
|
||||
if kind == "hint" {
|
||||
if res, err := DBExec("UPDATE team_hints SET coefficient = ? WHERE id_team = ? AND time = ? AND id_hint = ?", newCoeff, t.Id, h, givenId); err != nil {
|
||||
return 0, err
|
||||
|
|
@ -86,7 +86,7 @@ func (t Team) UpdateHistoryCoeff(kind string, h time.Time, givenId int64, newCoe
|
|||
}
|
||||
|
||||
// DelHistoryItem removes from the database an entry from the history.
|
||||
func (t Team) DelHistoryItem(kind string, h time.Time, primary *int64, secondary *int64) (interface{}, error) {
|
||||
func (t *Team) DelHistoryItem(kind string, h time.Time, primary *int64, secondary *int64) (interface{}, error) {
|
||||
if kind == "tries" && primary != nil {
|
||||
if res, err := DBExec("DELETE FROM exercice_tries WHERE id_team = ? AND time = ? AND id_exercice = ?", t.Id, h, *primary); err != nil {
|
||||
return 0, err
|
||||
|
|
|
|||
Reference in a new issue