-
Notifications
You must be signed in to change notification settings - Fork 1
/
school.go
54 lines (45 loc) · 1.13 KB
/
school.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
package main
import (
"encoding/json"
"io/ioutil"
"github.com/rs/zerolog/log"
)
type SchoolJSON struct {
Name string `json:"name"`
Slug string `json:"slug"`
Location string `json:"location"`
Address string `json:"address"`
Ranking string `json:"ranking"`
}
type School struct {
Name string `json:"name"`
Slug string `json:"slug"`
Location string `json:"location"`
Address string `json:"address"`
Ranking string `json:"ranking"`
Logo string `json:"logo"`
}
func getSchools(host string) []School {
var folder = "./school-logos"
log.Info().Msg("Called getSchools")
schoolJson, err := ioutil.ReadFile("./schools.json")
if err != nil {
log.Log().Err(err)
}
var schools []SchoolJSON
if err := json.Unmarshal(schoolJson, &schools); err != nil {
log.Log().Err(err)
}
var newSchools []School
for _, school := range schools {
newSchools = append(newSchools, School{
Name: school.Name,
Slug: school.Slug,
Location: school.Location,
Address: school.Address,
Ranking: school.Ranking,
Logo: host + "/logo/" + GetLogoUrl(folder, school.Slug) + ".png",
})
}
return newSchools
}