Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions api/services/gameService.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,22 @@ func (g gameService) Save(fileHeader *multipart.FileHeader, title string, owner
log.Println(fmt.Sprintf("Error reading game url: %s", err))
//We can ignore this error because we try it again in FindByID
//Maybe the deployment is not ready yet
} else {
updateGameStatus(&game)
}

return &game, g.repository.Save(&game)
}

func updateGameStatus(game *models.Game) {
//We set the game status to Installed if we have an url
if game.Url != "" {
game.Status = shared.Status_Installed
} else { //Otherwise we set it to Installing
game.Status = shared.Status_Installing
}
}

func (g gameService) Delete(id uuid.UUID) error {
//Get the game, we need the details to delete it from k8s
game, err := g.repository.FindByID(id)
Expand Down Expand Up @@ -132,6 +143,7 @@ func (g gameService) updateGameUrl(game *models.Game) {
//Maybe the deployment is not ready yet
} else {
game.Url = url
updateGameStatus(game)
//Save the changes in the database
err := g.repository.Save(game)
if err != nil {
Expand Down