~ethanmad/bouts.app

75124833a49f10a06dc1db82fa25f2c590181971 — Ethan Madison 1 year, 7 months ago 29bebc9
controllers/seeding: add support for FencingTime

This commit renames columns in the seeding CSV file and adds MemberNum
as a column so that Fencing Time can use the CSVs we export to seed
events.

Closes #11.

Signed-off-by: Ethan Madison <ethan@ethanmad.com>
1 files changed, 6 insertions(+), 4 deletions(-)

M controllers/seeding.go
M controllers/seeding.go => controllers/seeding.go +6 -4
@@ 75,21 75,23 @@ func (s *Seeding) Create(w http.ResponseWriter, r *http.Request) {

	switch seeding.Plurality {
	case models.Individuals:
		cw.Write([]string{"rank", "name", "schoolName", "elo"})
		cw.Write([]string{"Rank", "Name", "School", "MemberNum", "Elo"})
		for i := range seeding.Names {
			rank := strconv.Itoa(i + 1)
			name := seeding.Names[i]
			memberNum := strconv.FormatUint(uint64(seeding.IDs[i]), 10)
			schoolName := seeding.SchoolNames[i]
			elo := strconv.Itoa(seeding.Elos[i])
			cw.Write([]string{rank, name, schoolName, elo})
			cw.Write([]string{rank, name, schoolName, memberNum, elo})
		}
	case models.Squads:
		cw.Write([]string{"rank", "schoolName", "elo"})
		cw.Write([]string{"Rank", "School", "MemberNum", "Elo"})
		for i := range seeding.SchoolNames {
			rank := strconv.Itoa(i + 1)
			schoolName := seeding.SchoolNames[i]
			memberNum := strconv.FormatUint(uint64(seeding.IDs[i]), 10)
			elo := strconv.Itoa(seeding.Elos[i])
			cw.Write([]string{rank, schoolName, elo})
			cw.Write([]string{rank, schoolName, memberNum, elo})
		}
	default:
		views.RedirectAlert(w, r, "/seeding/new", http.StatusFound, *views.NewAlertErr(models.ErrPluralityInvalid))