diff --git a/.gitignore b/.gitignore index 89a67cec..335b9188 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ go.work.sum node_modules/ dist +.env \ No newline at end of file diff --git a/backend/onetime/seed-data/data/chofufes-2023.yaml b/backend/onetime/seed-data/data/chofufes-2023.yaml new file mode 100644 index 00000000..633ddd22 --- /dev/null +++ b/backend/onetime/seed-data/data/chofufes-2023.yaml @@ -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 diff --git a/backend/onetime/seed-data/data/nt-tokyo.yaml b/backend/onetime/seed-data/data/nt-tokyo.yaml index cf208dd8..20b11b08 100644 --- a/backend/onetime/seed-data/data/nt-tokyo.yaml +++ b/backend/onetime/seed-data/data/nt-tokyo.yaml @@ -1,6 +1,3 @@ -stations: - - yamashita - - umishita stop_rails: - yamashita_s1 - yamashita_s2 @@ -8,4 +5,4 @@ stop_rails: point_rails: - yamashita_p1 blocks: - - yamashita_b1 \ No newline at end of file + - yamashita_b1 diff --git a/backend/onetime/seed-data/main.go b/backend/onetime/seed-data/main.go index f93eef40..5758b394 100644 --- a/backend/onetime/seed-data/main.go +++ b/backend/onetime/seed-data/main.go @@ -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"` @@ -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{ diff --git a/map/chofufes-2023.yaml b/map/chofufes-2023.yaml index 8f2dbcd1..836a8f64 100644 --- a/map/chofufes-2023.yaml +++ b/map/chofufes-2023.yaml @@ -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