admin: add a new route to update team history coefficient

This commit is contained in:
nemunaire 2019-02-03 22:49:03 +01:00
parent 6a1f73c895
commit a35aa7be70
2 changed files with 52 additions and 4 deletions

View file

@ -238,10 +238,27 @@ func setTeamMember(team fic.Team, body []byte) (interface{}, error) {
}
type uploadedHistory struct {
Kind string
Time time.Time
Primary *int64
Secondary *int64
Kind string
Time time.Time
Primary *int64
Secondary *int64
Coefficient float32
}
func updateHistory(team *fic.Team, body []byte) (interface{}, error) {
var uh uploadedHistory
if err := json.Unmarshal(body, &uh); err != nil {
return nil, err
}
var givenId int64
if uh.Secondary != nil {
givenId = *uh.Secondary
} else if uh.Primary != nil {
givenId = *uh.Primary
}
return team.UpdateHistoryCoeff(uh.Kind, uh.Time, givenId, uh.Coefficient)
}
func delHistory(team *fic.Team, body []byte) (interface{}, error) {