File tree Expand file tree Collapse file tree 5 files changed +18
-17
lines changed Expand file tree Collapse file tree 5 files changed +18
-17
lines changed Original file line number Diff line number Diff line change
1
+ _constants /venues.json
Original file line number Diff line number Diff line change @@ -4,27 +4,18 @@ import (
4
4
"encoding/json"
5
5
"fmt"
6
6
"io"
7
+ "log"
7
8
"net/http"
8
9
9
- "github.com/nusmodifications/nusmods/website/api/optimiser/_constants"
10
- "github.com/nusmodifications/nusmods/website/api/optimiser/_models"
10
+ constants "github.com/nusmodifications/nusmods/website/api/optimiser/_constants"
11
+ models "github.com/nusmodifications/nusmods/website/api/optimiser/_models"
11
12
)
12
13
13
14
func GetVenues () (map [string ]models.Location , error ) {
14
15
venues := make (map [string ]models.Location )
15
- url := constants .VenuesURL
16
- res , err := http .Get (url )
17
- if err != nil {
18
- return nil , err
19
- }
20
- defer res .Body .Close ()
21
-
22
- body , err := io .ReadAll (res .Body )
23
- if err != nil {
24
- return nil , err
25
- }
26
- err = json .Unmarshal (body , & venues )
16
+ err := json .Unmarshal (constants .VenuesJson , & venues )
27
17
if err != nil {
18
+ log .Printf ("unable to load venues.json: %v" , err )
28
19
return nil , err
29
20
}
30
21
Original file line number Diff line number Diff line change 1
1
package constants
2
2
3
+ import (
4
+ _ "embed"
5
+ )
6
+
3
7
// Ensure in sync with all E-Venues in NUSMods
4
8
var E_Venues = map [string ]bool {
5
9
"E-Learn_A" : true ,
@@ -28,7 +32,8 @@ var LessonTypeAbbrev = map[string]string{
28
32
"WORKSHOP" : "WS" ,
29
33
}
30
34
31
- var VenuesURL = "https://github.nusmods.com/venues"
35
+ //go:embed venues.json
36
+ var VenuesJson []byte
32
37
33
38
var ModulesURL = "https://api.nusmods.com/v2/%s/modules/%s.json"
34
39
Original file line number Diff line number Diff line change 5
5
"scripts" : {
6
6
"start" : " cross-env NODE_ENV=development webpack serve --config webpack/webpack.config.dev.js" ,
7
7
"start:export" : " cross-env NODE_ENV=development OPEN_BROWSER=0 webpack serve --config webpack/webpack.config.timetable-only.js --port 8081" ,
8
- "start:optimiser" : " cd api/optimiser/_test && go run main.go" ,
9
- "build" : " cross-env NODE_ENV=production node scripts/build" ,
8
+ "start:optimiser" : " yarn prepare:optimiser && cd api/optimiser/_test && go run main.go" ,
9
+ "prepare:optimiser" : " cp src/data/venues.json api/optimiser/_constants" ,
10
+ "build" : " yarn prepare:optimiser && cross-env NODE_ENV=production node scripts/build" ,
10
11
"rsync" : " rsync -avu dist/" ,
11
12
"rsync:export" : " rsync -avu --delete-after dist-timetable/" ,
12
13
"promote-staging" : " bash scripts/promote-staging.sh" ,
Original file line number Diff line number Diff line change 3
3
"api/**/*.ts" : {
4
4
"excludeFiles" : " ./tsconfig.json" ,
5
5
"includeFiles" : " {./api/tsconfig.json,./src/serverless/*.xml}"
6
+ },
7
+ "api/**/*.go" : {
8
+ "includeFiles" : " ./api/optimiser/_constants/venues.json"
6
9
}
7
10
},
8
11
"headers" : [
You can’t perform that action at this time.
0 commit comments