示例#1
0
func FormatProgressSummaries(
	summaries []table.ProgressSummary) (rows []ProgressRow, err error) {

	for _, s := range summaries {
		var row ProgressRow

		row.Telephones, err = table.FindTelephonesForTeam(s.Team.TeamId)
		if err != nil {
			return nil, err
		}

		row.CompletedClueIds, row.RemainingClueIds = s.PartitionClues()

		row.TeamName = s.Team.Name
		row.Phrase = s.Team.Phrase
		row.TeamId = s.Team.TeamId

		if s.Team.StartTime.Valid {
			row.StartTime = s.Team.StartTime.Time.Unix()
		}

		if s.Team.FinishTime.Valid {
			row.FinishTimeResp = newFinishTimeResp(
				s.Team.StartTime, s.Team.FinishTime.Time, s.TotalHintsTaken,
			)
		} else {
			row.FinishTimeResp.HintsTaken = s.TotalHintsTaken
		}

		if s.CurrentClue != nil {

			row.ClueDescription = s.CurrentClue.Description
			row.ClueId = s.CurrentClue.ClueId
			row.ClueText = s.CurrentClue.Text
		}

		rows = append(rows, row)
	}

	return
}
示例#2
0
func TestFindTelephonesForTeam(t *T) {
	beforeTeamTest()
	numbers, err := table.FindTelephonesForTeam(100)
	rdtest.Assert(t, err == nil, err)
	rdtest.Assert(t, len(numbers) == 2)
}