Skip to content

Commit

Permalink
Merge pull request #139 from Arquisoft/develop
Browse files Browse the repository at this point in the history
✨ Merge with changes in main page tests
  • Loading branch information
uo264915 authored Apr 18, 2024
2 parents 3fdd330 + daf806e commit cf2cd09
Show file tree
Hide file tree
Showing 40 changed files with 21,513 additions and 347 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added docs/images/DOCsection5_2.drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/images/DOCsection5_2.png
Binary file not shown.
Binary file added docs/images/DOCsection5_3.drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/images/DOCsection5_3.png
Binary file not shown.
Binary file added docs/images/DOCsection8_1.drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/images/DOCsection8_1.png
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/src/03_system_scope_and_context.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ The agents involved in the WIQ system environment are the following:



image::03-TechnicalContextDiagram-Lucidchart.png[Technical Context Diagram]
image::03-TechnicalContextDiagram-Lucidchart.jpeg[Technical Context Diagram]

.WIQ
[cols="1,2,3"]
Expand Down
71 changes: 42 additions & 29 deletions docs/src/05_building_block_view.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ WIQ is the general structure of the system, where the users are going to registe
|===
| Name | Description

| *_Actor_*
| *_User_*
| Client/User of the application which will interact with it.

| *_WIQ application_*
Expand All @@ -31,7 +31,7 @@ WIQ is the general structure of the system, where the users are going to registe

=== Level 2

image::DOCsection5_2.png["Level 2"]
image::DOCsection5_2.drawio.png["Level 2"]

.Motivation
Shows how is the system internally in general terms.
Expand All @@ -42,22 +42,29 @@ Shows how is the system internally in general terms.
|===
| Name | Description

| *_User_*
| Client/User of the application which will interact with it.

| *_Webapp_*
| It contains the user interface (frontend) and the development branch (backend).

| *_Users API_*
| API to manage all the functionalities related to users.
| *_Microservices_*
| Part that takes care of the functionalities.

| *_Questions API_*
| API to manage all the functionalities related to questions/answers.
| *_WIQ_*
| Main component that manages all the system.

| *_MongoDB_*
| Database where user data is recorded and stored.
|===
| *_Wikidata_*
| Website where to get information for questions.

| *_Database_*
| Component that manages the authentification of users.

|===

=== Level 3

image::DOCsection5_3.png["Level 3"]
image::DOCsection5_3.drawio.png["Level 3"]

.Motivation
Detailed structure of the system. Focused on the components of the Webapp, Users API and Questions API.
Expand All @@ -68,6 +75,9 @@ Detailed structure of the system. Focused on the components of the Webapp, Users
|===
| Name | Description

| *_User_*
| Client/User of the application which will interact with it.

| *_Games History_*
| Component to store games played by each user and where user can watch their previous games.

Expand All @@ -77,33 +87,36 @@ Detailed structure of the system. Focused on the components of the Webapp, Users
| *_Questions History_*
| Component to store previous questions and where user can watch them.

| *_Home_*
| Initial screen of the application.
| *_Main Page_*
| Component that shows the main functionalities of the system.

| *_Register Users_*
| Component to see what users are registered on the system.

| *_Login_*
| Component to access the system by the user.

| *_Menu_*
| Component to navigate through the system.

| *_Help_*
| Offers help to the user.
| *_Users Service_*
| Component that manages the creation of new users.

| *_About_*
| Adds info about the development of the project.
| *_Questions Service_*
| Component that manages the creation of the questions.

| *_AddUser_*
| Component to create a new user.

| *_Login_*
| Component to access the system by the user.
| *_Historial Service_*
| Component that manages the history of users.

| *_Profile_*
| Component to store and manage the user data.
| *_Authentification Service_*
| Component that manages the authentification of users.

| *_Game_*
| Component to create a new game.
| *_WIQ_*
| Main component that manages all the system.

| *_NewQuestion_*
| Component to create new questions for the games.
| *_Wikidata_*
| Website where to get information for questions.

| *_UsedQuestions_*
| Component to store and manage the used questions.
| *_Database_*
| Component that manages the authentification of users.
|===
2 changes: 1 addition & 1 deletion docs/src/08_concepts.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ifndef::imagesdir[:imagesdir: ../images]

=== Domain model

image::DOCsection8_1.png["Domain model"]
image::DOCsection8_1.drawio.png["Domain model"]

=== Performance
A system that performs well provides a positive user experience. Users expect applications and services to respond promptly to their requests. A higher performance leads to increased user satisfaction and engagement. Also, a good performance help to get a better efficiency.
Expand Down
23 changes: 21 additions & 2 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ app.post('/adduser', async (req, res) => {

app.post('/addgame', async (req, res) => {
try {
const userResponse = await axios.post(userServiceUrl+'/addgame', req.body);
const userResponse = await axios.post(retrieveServiceUrl+'/addgame', req.body);
res.json(userResponse.data);
} catch (error) {
res.status(error.response.status).json({ error: error.response.data.error });
Expand All @@ -60,7 +60,15 @@ app.post('/addgame', async (req, res) => {
app.get('/getgamehistory/:username', async (req, res) => {
try {
const username = req.params.username;
const userResponse = await axios.get(`${userServiceUrl}/getgamehistory/${username}`);
const userResponse = await axios.get(`${retrieveServiceUrl}/getgamehistory/${username}`);
res.json(userResponse.data);
} catch (error) {
res.status(error.response.status).json({ error: error.response.data.error });
}
});
app.get('/getScoreBoard', async (req, res) => {
try {
const userResponse = await axios.get(`${retrieveServiceUrl}/getScoreBoard`);
res.json(userResponse.data);
} catch (error) {
res.status(error.response.status).json({ error: error.response.data.error });
Expand Down Expand Up @@ -91,6 +99,17 @@ app.get('/getquestionshistory', async (req, res) => {
}
});

app.get('/getregisteredusers', async (req, res) => {
try {
// Create a petition to the URL (le llegará a retrieve-service.js) with the option /getregisteredusers and the req.body params
const registeredUsersResponse = await axios.get(userServiceUrl+'/getregisteredusers', req.body);
// Return a json response with what we obtained on the petition
res.json(registeredUsersResponse.data);
} catch (error) {
res.status(error.response.status).json({ error: error.response.data.error });
}
});



// Read the OpenAPI YAML file synchronously
Expand Down
91 changes: 90 additions & 1 deletion gatewayservice/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,93 @@ paths:
error:
type: string
description: Error information.
example: User not found.
example: User not found.

/getScoreBoard:
get:
summary: Get the scoreboard.
operationId: getScoreBoard
responses:
'200':
description: Scoreboard retrieved successfully.
content:
application/json:
schema:
type: array
items:
type: object
properties:
username:
type: string
description: Username of the player.
example: player1
score:
type: integer
description: Score achieved by the player.
example: 100

/createquestion:
get:
summary: Create a new question.
operationId: createQuestion
responses:
'200':
description: Question created successfully.
content:
application/json:
schema:
type: object
properties:
question:
type: string
description: The created question.
example: What is the capital of France?
answer:
type: string
description: The answer to the question.
example: Paris


/getquestionshistory:
get:
summary: Get the history of generated questions.
operationId: getQuestionsHistory
responses:
'200':
description: Questions history retrieved successfully.
content:
application/json:
schema:
type: array
items:
type: object
properties:
question:
type: string
description: The question.
example: What is 2 + 2?
answer:
type: integer
description: The correct answer to the question.
example: 4



/getregisteredusers:
get:
summary: Get the list of registered users.
operationId: getRegisteredUsers
responses:
'200':
description: List of registered users retrieved successfully.
content:
application/json:
schema:
type: array
items:
type: object
properties:
username:
type: string
description: Username of the registered user.
example: user1
2 changes: 1 addition & 1 deletion questions/creationservice/creation-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var randomQuerySelector;
// Array of the possible queries
var queries = ['SELECT DISTINCT ?questionObject ?questionObjectLabel ?answer ?answerLabel WHERE { ?questionObject wdt:P31 wd:Q6256. ?questionObject wdt:P36 ?answer. SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],es".}}'];
// Array of the possible questions
var questions = ["¿Cual es la capital de "];
var questions = ["¿Cuál es la capital de "];

// Recieves the information of the query and select wich data use on the question
function getQuestionInfo(info){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const mongoose = require('mongoose');
const gameSchema = new mongoose.Schema({
username: { type: String, required: true },
duration: Number,
questions: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Question' }],
questions: [{ type: mongoose.Schema.Types.ObjectId, ref: 'QuestionAnswered' }],
date: { type: Date, default: Date.now } ,
percentage: Number,
totalQuestions: Number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ const questionSchema = new mongoose.Schema({
userAnswer: String
});

const Question = mongoose.model('Question', questionSchema);
const QuestionAnswered = mongoose.model('QuestionAnswered', questionSchema);

module.exports = Question;
module.exports = QuestionAnswered
Loading

0 comments on commit cf2cd09

Please sign in to comment.