Skip to content

Commit

Permalink
add config
Browse files Browse the repository at this point in the history
  • Loading branch information
csenet committed Nov 22, 2023
1 parent 81dab60 commit 4530de2
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 61 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
go.work.sum
node_modules/
dist
.env
40 changes: 40 additions & 0 deletions backend/onetime/seed-data/data/chofufes-2023.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
stop_rails:
- shinjuku_s1
- shinjuku_s2
- sakurajosui_s0
- sakurajosui_s1
- sakurajosui_s2
- sakurajosui_s3
- sakurajosui_s4
- sakurajosui_s5
- chofu_s0
- chofu_s1
- chofu_s2
- chofu_s3
- chofu_s4
- hashimoto_s1
- hashimoto_s2
- hachioji_s1
- hachioji_s2
point_rails:
- sakurajosui_p1
- sakurajosui_p2
- chofu_p1
blocks:
- shinjuku_b1
- shinjuku_b2
- sakurajosui_b1
- sakurajosui_b2
- sakurajosui_b3
- sakurajosui_b4
- sakurajosui_b5
- sakurajosui_b6
- chofu_b1
- chofu_b2
- chofu_b3
- chofu_b4
- chofu_b5
- hashimoto_b1
- hashimoto_b2
- hachioji_b1
- hachioji_b2
5 changes: 1 addition & 4 deletions backend/onetime/seed-data/data/nt-tokyo.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
stations:
- yamashita
- umishita
stop_rails:
- yamashita_s1
- yamashita_s2
- umishita_s1
point_rails:
- yamashita_p1
blocks:
- yamashita_b1
- yamashita_b1
46 changes: 22 additions & 24 deletions backend/onetime/seed-data/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ import (
"gopkg.in/yaml.v3"
)

type Station string
type StopRail string
type PointRail string
type Block string

type Seed struct {
Stations []Station `yaml:"stations"`
StopRails []StopRail `yaml:"stop_rails"`
PointRails []PointRail `yaml:"point_rails"`
Blocks []Block `yaml:"blocks"`
Expand All @@ -35,32 +33,32 @@ func main() {
}
defer db.Close()
data := &Seed{}
b, _ := os.ReadFile("./data/nt-tokyo.yaml")
b, _ := os.ReadFile("./data/chofufes-2023.yaml")
if err := yaml.Unmarshal(b, data); err != nil {
panic(err)
}

//for _, stop := range data.StopRails {
// println(stop)
// err := db.AddStop(&trainv1.StopAndState{
// Id: string(stop),
// State: trainv1.StopStateEnum_STOP_STATE_GO,
// })
// if err != nil {
// return
// }
//}
//
//for _, point := range data.PointRails {
// println(point)
// err := db.AddPoint(&trainv1.PointAndState{
// Id: string(point),
// State: trainv1.PointStateEnum_POINT_STATE_NORMAL,
// })
// if err != nil {
// return
// }
//}
for _, stop := range data.StopRails {
println(stop)
err := db.AddStop(&statev1.StopAndState{
Id: string(stop),
State: statev1.StopStateEnum_STOP_STATE_GO,
})
if err != nil {
return
}
}

for _, point := range data.PointRails {
println(point)
err := db.AddPoint(&statev1.PointAndState{
Id: string(point),
State: statev1.PointStateEnum_POINT_STATE_NORMAL,
})
if err != nil {
return
}
}
for _, block := range data.Blocks {
println(block)
err := db.AddBlock(&statev1.BlockState{
Expand Down
64 changes: 31 additions & 33 deletions map/chofufes-2023.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
- stations:
- name: "調布"
id: chofu_up
capacity: 2
- name: "調布"
id: chofu_down
capacity: 2
- name: "新宿"
id: shinjyuku_up
capacity: 2
- name: "新宿"
id: shinjyuku_down
capacity: 2
- name: "橋本"
id: hashimoto_up
capacity: 2
- name: "橋本"
id: hashimoto_down
capacity: 2
- name: "調布"
id: chofu_up
capacity: 2
- name: "調布"
id: chofu_down
capacity: 2
- name: "新宿"
id: shinjyuku_up
capacity: 2
- name: "新宿"
id: shinjyuku_down
capacity: 2
- name: "橋本"
id: hashimoto_up
capacity: 2
- name: "橋本"
id: hashimoto_down
capacity: 2

- routes:
- name: 本線
path:
- chofu_up
- shinjyuku_up
- shinjyuku_down
- chofu_down
- chofu_up
- name: 相模原線
path:
- chofu_up
- hashimoto_up
- hashimoto_down
- chofu_down


- name: 本線
path:
- chofu_up
- shinjyuku_up
- shinjyuku_down
- chofu_down
- chofu_up
- name: 相模原線
path:
- chofu_up
- hashimoto_up
- hashimoto_down
- chofu_down

0 comments on commit 4530de2

Please sign in to comment.