diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-07-03 17:22:14 +0000 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-07-03 17:22:14 +0000 |
| commit | 50f5fff2873847b3e5df92d204e5166b641baeb2 (patch) | |
| tree | bf7bc18c8dc95dff1fb9741617ff23d8429127de /backend/controllers | |
| parent | fix: change demo save location (diff) | |
| download | lphub-50f5fff2873847b3e5df92d204e5166b641baeb2.tar.gz lphub-50f5fff2873847b3e5df92d204e5166b641baeb2.tar.bz2 lphub-50f5fff2873847b3e5df92d204e5166b641baeb2.zip | |
fix: parser actually works now (#42)
Former-commit-id: 28378525f79e2879a1306b3bb169668d238cc117
Diffstat (limited to 'backend/controllers')
| -rw-r--r-- | backend/controllers/recordController.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/backend/controllers/recordController.go b/backend/controllers/recordController.go index 28c55e0..1c0f3b2 100644 --- a/backend/controllers/recordController.go +++ b/backend/controllers/recordController.go | |||
| @@ -71,7 +71,10 @@ func CreateRecordWithDemo(c *gin.Context) { | |||
| 71 | return | 71 | return |
| 72 | } | 72 | } |
| 73 | // Demo files | 73 | // Demo files |
| 74 | demoFiles := []*multipart.FileHeader{record.HostDemo, record.PartnerDemo} | 74 | demoFiles := []*multipart.FileHeader{record.HostDemo} |
| 75 | if isCoop { | ||
| 76 | demoFiles = append(demoFiles, record.PartnerDemo) | ||
| 77 | } | ||
| 75 | var hostDemoUUID, hostDemoFileID, partnerDemoUUID, partnerDemoFileID string | 78 | var hostDemoUUID, hostDemoFileID, partnerDemoUUID, partnerDemoFileID string |
| 76 | var hostDemoScoreCount, hostDemoScoreTime int | 79 | var hostDemoScoreCount, hostDemoScoreTime int |
| 77 | client := serviceAccount() | 80 | client := serviceAccount() |
| @@ -91,12 +94,12 @@ func CreateRecordWithDemo(c *gin.Context) { | |||
| 91 | for i, header := range demoFiles { | 94 | for i, header := range demoFiles { |
| 92 | uuid := uuid.New().String() | 95 | uuid := uuid.New().String() |
| 93 | // Upload & insert into demos | 96 | // Upload & insert into demos |
| 94 | err = c.SaveUploadedFile(header, "backend/parser/demos/"+header.Filename) | 97 | err = c.SaveUploadedFile(header, "backend/parser/"+header.Filename) |
| 95 | if err != nil { | 98 | if err != nil { |
| 96 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) | 99 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) |
| 97 | return | 100 | return |
| 98 | } | 101 | } |
| 99 | f, err := os.Open("backend/parser/demos/" + header.Filename) | 102 | f, err := os.Open("backend/parser/" + header.Filename) |
| 100 | if err != nil { | 103 | if err != nil { |
| 101 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) | 104 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) |
| 102 | return | 105 | return |
| @@ -107,7 +110,7 @@ func CreateRecordWithDemo(c *gin.Context) { | |||
| 107 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) | 110 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) |
| 108 | return | 111 | return |
| 109 | } | 112 | } |
| 110 | hostDemoScoreCount, hostDemoScoreTime, err = parser.ProcessDemo("backend/parser/demos/" + header.Filename) | 113 | hostDemoScoreCount, hostDemoScoreTime, err = parser.ProcessDemo("backend/parser/" + header.Filename) |
| 111 | if err != nil { | 114 | if err != nil { |
| 112 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) | 115 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) |
| 113 | return | 116 | return |
| @@ -125,7 +128,7 @@ func CreateRecordWithDemo(c *gin.Context) { | |||
| 125 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) | 128 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) |
| 126 | return | 129 | return |
| 127 | } | 130 | } |
| 128 | os.Remove("backend/parser/demos/" + header.Filename) | 131 | os.Remove("backend/parser/" + header.Filename) |
| 129 | } | 132 | } |
| 130 | // Insert into records | 133 | // Insert into records |
| 131 | if isCoop { | 134 | if isCoop { |