summaryrefslogtreecommitdiff
path: root/index.go
diff options
context:
space:
mode:
Diffstat (limited to 'index.go')
-rw-r--r--index.go27
1 files changed, 18 insertions, 9 deletions
diff --git a/index.go b/index.go
index 508c5ae..4617b98 100644
--- a/index.go
+++ b/index.go
@@ -111,12 +111,21 @@ func handleIndex(w http.ResponseWriter, req *http.Request) {
return
}
- /*
- * Copy courses to _courses. The former is a sync.Map and the latter is
- * a map[int]*courseT, and the former is very difficult to access from
- * HTML templates.
- */
- _courses := make(map[int]*courseT)
+ /* TODO: The below should be completed on-update. */
+ type groupT struct {
+ Handle courseGroupT
+ Name string
+ Courses *map[int]*courseT
+ }
+ _groups := make(map[courseGroupT]groupT)
+ for k, v := range courseGroups {
+ _coursemap := make(map[int]*courseT)
+ _groups[k] = groupT{
+ Handle: k,
+ Name: v,
+ Courses: &_coursemap,
+ }
+ }
courses.Range(func(key, value interface{}) bool {
courseID, ok := key.(int)
if !ok {
@@ -126,7 +135,7 @@ func handleIndex(w http.ResponseWriter, req *http.Request) {
if !ok {
panic("courses map has non-\"*courseT\" items")
}
- _courses[courseID] = course
+ (*_groups[course.Group].Courses)[courseID] = course
return true
})
@@ -139,12 +148,12 @@ func handleIndex(w http.ResponseWriter, req *http.Request) {
Open bool
Name string
Department string
- Courses *map[int]*courseT
+ Groups *map[courseGroupT]groupT
}{
true,
userName,
userDepartment,
- &_courses,
+ &_groups,
},
)
}()