admin: add a new route to update team history coefficient
This commit is contained in:
parent
6a1f73c895
commit
a35aa7be70
2 changed files with 52 additions and 4 deletions
|
@ -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) {
|
||||
|
|
Reference in a new issue