Skip to content

Commit

Permalink
OpenAPI update y botón finalizar
Browse files Browse the repository at this point in the history
  • Loading branch information
UO277938 committed Apr 28, 2024
1 parent c439ab6 commit 3f8d931
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 93 deletions.
4 changes: 2 additions & 2 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ app.get('/getUserData', async (req, res) => {
const { username } = req.query;
try{
const getUserDataResponse = await axios.get(userServiceUrl+ `/getUserData?username=${username}`)
res.json(getUserDataResponse.data);
res.status(200).json(getUserDataResponse.data);
}catch(error){
res.status(error.response.status).json({error: error.response.data.error});
}
Expand All @@ -102,7 +102,7 @@ app.get('/getUserData', async (req, res) => {
app.get('/getUsernames', async (req, res) => {
try{
const getUserDataResponse = await axios.get(userServiceUrl+ `/getUsernames`)
res.json(getUserDataResponse.data);
res.status(200).json(getUserDataResponse.data);
}catch(error){
res.status(error.response.status).json({error: error.response.data.error});
}
Expand Down
125 changes: 35 additions & 90 deletions gatewayservice/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,21 +183,23 @@ paths:
type: string
description: Error information.
example: Internal Server Error
/updateCorrectAnswers:
/updateStats:
get:
summary: Updates the data of the user, increasing his number of correct answers.
operationId: updateCorrectAnswers
operationId: updateStats
parameters:
in: path
name: params
required: true
description: Parameters for the update (username and numAnswers)
description: Parameters for the update (username, numRespuestsasCorrectas, numRespuestasIncorrectas)
schema:
type: object
properties:
username:
type: string
numAnswers:
numRespuestsasCorrectas:
type: integer
numRespuestasIncorrectas:
type: integer
responses:
'200':
Expand All @@ -213,63 +215,16 @@ paths:
message:
type: string
example: Respuestas correctas actualizada con éxito
'404':
description: The user is not found.
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: false
message:
type: string
example: Usuario no encontrado
'500':
description: Internal server error.
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: false
message:
type: string
description: Error information.
example: Error al actualizar las respuestas correctas
/updateIncorrectAnswers:
get:
summary: Updates the data of the user, increasing his number of incorrect answers.
operationId: updateIncorrectAnswers
parameters:
in: path
name: params
required: true
description: Parameters for the update (username and numAnswers)
schema:
type: object
properties:
username:
type: string
numAnswers:
type: integer
responses:
'200':
description: Updates the data correctly.
'401':
description: Params needed for the get action.
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: true
message:
error:
type: string
example: Respuestas incorrectas actualizada con éxito
example: Faltan parámetros en la solicitud.
'404':
description: The user is not found.
content:
Expand All @@ -296,16 +251,16 @@ paths:
message:
type: string
description: Error information.
example: Error al actualizar las respuestas incorrectas
/updateCompletedGames:
example: Error al actualizar las respuestas correctas
/getUserData:
get:
summary: Update the number of completed games by the user.
operationId: updateCompletedGames
summary: Gets the data of an user.
operationId: getUserData
parameters:
in: path
name: username
required: true
description: Username for the update of data
description: Username for the search of data
schema:
type: string
responses:
Expand All @@ -316,12 +271,22 @@ paths:
schema:
type: user
properties:
success:
type: boolean
example: true
message:
username:
type: string
example: Juegos completados actualizado con éxito
example: Pablo
password:
type: integer
example: pass
createdAt:
type: date
correctAnswers:
type: integer
incorrectAnswers:
type: integer
completedGames:
type: integer
averageTime:
type: integer
'404':
description: The user is not found.
content:
Expand All @@ -348,21 +313,14 @@ paths:
message:
type: string
description: Error information.
example: Error al actualizar Juegos completados
/getUserData:
example: Error al obtener los datos de usuario
/getUsernames:
get:
summary: Gets the data of an user.
operationId: getUserData
parameters:
in: path
name: username
required: true
description: Username for the search of data
schema:
type: string
summary: Gets all the usernames.
operationId: getUsernames
responses:
'200':
description: Finds the data of the user correctly.
description: Finds the data of the user correctly (or no users).
content:
application/json:
schema:
Expand All @@ -384,19 +342,6 @@ paths:
type: integer
averageTime:
type: integer
'404':
description: The user is not found.
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: false
message:
type: string
example: Usuario no encontrado
'500':
description: Internal server error.
content:
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/components/Pages/Juego.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ const Juego = ({isLogged, username, numPreguntas}) => {
{finishGame ? <>
<h2> PARTIDA FINALIZADA </h2>
<h2> ACERTADAS: {numRespuestasCorrectas} FALLADAS: {numRespuestasIncorrectas} </h2>
<button id="botonFinal" className="button" disabled={disableFinish} onClick={() => {clickFinalizar()}} > FINALIZAR PARTIDA</button>
{ !disableFinish ? <button id="botonFinal" className="button" disabled={disableFinish} onClick={() => {clickFinalizar()}} > GUARDAR ESTADÍSTICAS</button>
: <></> }
</> : <></>}

{ disableFinish ? ( <h2> Comience nueva partida o visite sus estadísticas!!</h2>)
Expand Down

0 comments on commit 3f8d931

Please sign in to comment.