Exemplo n.º 1
0
func setTeamFinish(ctx *_Context) error {
	teamId := ctx.urlParams["team_id"].(int64)

	team, err := table.FindTeam(teamId)
	if err != nil {
		return err
	}

	if ctx.r.Method == "DELETE" {
		ctx.resp = &_TeamFinishResp{}
		return table.UpdateTeamFinishTime(teamId, nil)
	}

	now := time.Now()
	if err := table.UpdateTeamFinishTime(teamId, &now); err != nil {
		return err
	}

	hintsTaken, err := table.FindHintsTakenForTeam(teamId)
	if err != nil {
		return err
	}

	ctx.resp = newFinishTimeResp(team.StartTime, now, hintsTaken)
	return nil
}
Exemplo n.º 2
0
func TestFindHintsTakenForTeam(t *T) {
	beforeTeamProgressTest()
	hints, err := table.FindHintsTakenForTeam(21)
	rdtest.Assert(t, err == nil, err)
	rdtest.Assert(t, hints == 3, "%d", hints)
}