-
Notifications
You must be signed in to change notification settings - Fork 0
/
event.go
69 lines (60 loc) · 1.42 KB
/
event.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package otrscouting
import (
"github.com/gin-gonic/gin"
"strconv"
"strings"
)
type EventRoot struct {
EventCode string
EventDate string
EventId string
EventName string
FRCEvents string
Year int
}
type EventTemplate struct {
EventName string
FRCEvents string
EventCode string
EventDate string
Year int
QualMatches []MatchTemplate
TeamTable []PowerUpRobot
}
type MatchTemplate struct {
MatchNumber string
Red1 RobotTemplate
Red2 RobotTemplate
Red3 RobotTemplate
Blue1 RobotTemplate
Blue2 RobotTemplate
Blue3 RobotTemplate
redScore int // Unused ATM
blueScore int // Unused ATM
MatchId string
}
func (m MatchTemplate) Level() string {
if strings.Split(m.MatchId, "_")[2][0] == 'q' {
return "Qualifications"
}
return "Playoffs"
}
func (m MatchTemplate) FriendlyName() string {
return m.Level() + ": Match " + m.MatchNumber
}
func (m MatchTemplate) EventId() string {
return strings.Split(m.MatchId, "_")[1]
}
func (m MatchTemplate) Year() int {
year, _ := strconv.Atoi(strings.Split(m.MatchId, "_")[0])
return year
}
// Format: /event/:event
func GinEventHandler(c *gin.Context) {
eventCode := c.Param("event")
tmpl := GetPageTemplate("event.html", c)
data := getEvent(c, eventCode)
data.QualMatches = getEventMatches(c, eventCode)
data.TeamTable = sumeventrobotsPowerup(c, getEventRobots(c, eventCode))
tmpl.Execute(c.Writer, data)
}