aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/database/chapters.sql34
-rw-r--r--backend/database/init.sql1
-rw-r--r--backend/handlers/map.go4
-rw-r--r--backend/models/models.go5
4 files changed, 23 insertions, 21 deletions
diff --git a/backend/database/chapters.sql b/backend/database/chapters.sql
index 9538bed..f61d5bf 100644
--- a/backend/database/chapters.sql
+++ b/backend/database/chapters.sql
@@ -1,17 +1,17 @@
1INSERT INTO chapters(id, game_id, name) VALUES 1INSERT INTO chapters(id, game_id, name, is_disabled) VALUES
2(1, 1, 'Chapter 1 - The Coutesy Call'), 2(1, 1, 'Chapter 1 - The Coutesy Call', false),
3(2, 1, 'Chapter 2 - The Cold Boot'), 3(2, 1, 'Chapter 2 - The Cold Boot', false),
4(3, 1, 'Chapter 3 - The Return'), 4(3, 1, 'Chapter 3 - The Return', false),
5(4, 1, 'Chapter 4 - The Surprise'), 5(4, 1, 'Chapter 4 - The Surprise', false),
6(5, 1, 'Chapter 5 - The Escape'), 6(5, 1, 'Chapter 5 - The Escape', false),
7(6, 1, 'Chapter 6 - The Fall'), 7(6, 1, 'Chapter 6 - The Fall', false),
8(7, 1, 'Chapter 7 - The Reunion'), 8(7, 1, 'Chapter 7 - The Reunion', false),
9(8, 1, 'Chapter 8 - The Itch'), 9(8, 1, 'Chapter 8 - The Itch', false),
10(9, 1, 'Chapter 9 - The Part Where He Kills You'), 10(9, 1, 'Chapter 9 - The Part Where He Kills You', false),
11(10, 2, 'Course 0 - Introduction'), 11(10, 2, 'Course 0 - Introduction', true),
12(11, 2, 'Course 1 - Team Building'), 12(11, 2, 'Course 1 - Team Building', false),
13(12, 2, 'Course 2 - Mass And Velocity'), 13(12, 2, 'Course 2 - Mass And Velocity', false),
14(13, 2, 'Course 3 - Hard-Light Surfaces'), 14(13, 2, 'Course 3 - Hard-Light Surfaces', false),
15(14, 2, 'Course 4 - Excursion Funnels'), 15(14, 2, 'Course 4 - Excursion Funnels', false),
16(15, 2, 'Course 5 - Mobility Gels'), 16(15, 2, 'Course 5 - Mobility Gels', false),
17(16, 2, 'Course 6 - Art Therapy'); \ No newline at end of file 17(16, 2, 'Course 6 - Art Therapy', false); \ No newline at end of file
diff --git a/backend/database/init.sql b/backend/database/init.sql
index 17a0ce5..9851ad7 100644
--- a/backend/database/init.sql
+++ b/backend/database/init.sql
@@ -23,6 +23,7 @@ CREATE TABLE chapters (
23 id SERIAL, 23 id SERIAL,
24 game_id SMALLINT NOT NULL, 24 game_id SMALLINT NOT NULL,
25 name TEXT NOT NULL, 25 name TEXT NOT NULL,
26 is_disabled BOOLEAN NOT NULL DEFAULT false,
26 PRIMARY KEY (id), 27 PRIMARY KEY (id),
27 FOREIGN KEY (game_id) REFERENCES games(id) 28 FOREIGN KEY (game_id) REFERENCES games(id)
28); 29);
diff --git a/backend/handlers/map.go b/backend/handlers/map.go
index d8f2ff0..8b8b9d7 100644
--- a/backend/handlers/map.go
+++ b/backend/handlers/map.go
@@ -365,7 +365,7 @@ func FetchChapters(c *gin.Context) {
365 return 365 return
366 } 366 }
367 var response ChaptersResponse 367 var response ChaptersResponse
368 rows, err := database.DB.Query(`SELECT c.id, c.name, g.name FROM chapters c INNER JOIN games g ON c.game_id = g.id WHERE game_id = $1`, gameID) 368 rows, err := database.DB.Query(`SELECT c.id, c.name, g.name, c.is_disabled FROM chapters c INNER JOIN games g ON c.game_id = g.id WHERE game_id = $1`, gameID)
369 if err != nil { 369 if err != nil {
370 c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) 370 c.JSON(http.StatusOK, models.ErrorResponse(err.Error()))
371 return 371 return
@@ -374,7 +374,7 @@ func FetchChapters(c *gin.Context) {
374 var gameName string 374 var gameName string
375 for rows.Next() { 375 for rows.Next() {
376 var chapter models.Chapter 376 var chapter models.Chapter
377 if err := rows.Scan(&chapter.ID, &chapter.Name, &gameName); err != nil { 377 if err := rows.Scan(&chapter.ID, &chapter.Name, &gameName, &chapter.IsDisabled); err != nil {
378 c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) 378 c.JSON(http.StatusOK, models.ErrorResponse(err.Error()))
379 return 379 return
380 } 380 }
diff --git a/backend/models/models.go b/backend/models/models.go
index c380a89..3aa2e9c 100644
--- a/backend/models/models.go
+++ b/backend/models/models.go
@@ -92,8 +92,9 @@ type Game struct {
92} 92}
93 93
94type Chapter struct { 94type Chapter struct {
95 ID int `json:"id"` 95 ID int `json:"id"`
96 Name string `json:"name"` 96 Name string `json:"name"`
97 IsDisabled bool `json:"is_disabled"`
97} 98}
98 99
99type Category struct { 100type Category struct {