Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service question generator #132

Merged
merged 27 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2d6536c
Merge branch 'develop' into wikidata_queries
uo288574 Mar 29, 2024
7f0fb21
Merge branch 'develop' into wikidata_queries
uo288574 Apr 1, 2024
73efd4c
new queries
uo288574 Apr 8, 2024
c00bc9d
borrada query innecesaria
uo288574 Apr 10, 2024
d02d9dd
Merge branch 'master' into wikidata_queries
uo288574 Apr 12, 2024
4a35c17
consultation for country and monument
uo288574 Apr 12, 2024
c2ee62c
F1 queries
uo288574 Apr 14, 2024
75d3e62
sport queries
uo288574 Apr 18, 2024
ac99ae5
new query
uo288574 Apr 18, 2024
7808ccd
Refactoriced WikidataExtractor in order to make it extensible and to …
AbelMH1 Apr 25, 2024
431dea8
Merge branch 'wikidata_queries' into service_question_generator
AbelMH1 Apr 25, 2024
3dcc27d
Añadido filtro a los datos obtenidos de wikidata para los campos no d…
AbelMH1 Apr 25, 2024
60af73c
Fixed bug that was producing the queries to be executed when starting…
AbelMH1 Apr 25, 2024
6a6f533
Added the chemical elements data extraction
AbelMH1 Apr 26, 2024
d36c800
Added queries and templates for extracting data about different topics
AbelMH1 Apr 26, 2024
351dd34
Added the extraction templates for new data topics and a new method t…
AbelMH1 Apr 28, 2024
295bb61
Fixed languaje on the query MonumentoYPais
AbelMH1 Apr 28, 2024
850ae58
Moddified the information showed in the WikidataExtractor console logs
AbelMH1 Apr 28, 2024
1adf724
Modified the information showed in the QuestionGenerator console logs
AbelMH1 Apr 28, 2024
4560018
Commented Develop only endpoints
AbelMH1 Apr 28, 2024
4f29434
npm audit fix
AbelMH1 Apr 28, 2024
75489c4
Added containers to the sonar-cloud code checker
AbelMH1 Apr 28, 2024
12b75bd
Merge branch 'develop' into service_question_generator
AbelMH1 Apr 28, 2024
e0624cf
Trying to clean my code
AbelMH1 Apr 29, 2024
a6f912c
Extracted the identical data models from the two services to a common…
AbelMH1 Apr 29, 2024
f3b4bfd
Corrected the data extraction interval time for production
AbelMH1 Apr 29, 2024
38288c2
Merge branch 'develop' into service_question_generator
AbelMH1 Apr 29, 2024
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
10 changes: 8 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ services:
container_name: questiongeneratorservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es6c/questiongeneratorservice:latest
profiles: ["dev", "prod"]
build: ./questionsservice/questiongeneratorservice
build:
context: ./questionsservice
dockerfile: ./questiongeneratorservice/Dockerfile
depends_on:
- mongodb_wiki
- storequestionservice
Expand All @@ -100,6 +102,7 @@ services:
networks:
- mynetwork
environment:
DATAMODELS_URI: './questiondata-model'
MONGODB_URI: mongodb://mongodb_wiki:27017/questions
STORE_QUESTION_SERVICE_URL: http://storequestionservice:8004
restart: always
Expand All @@ -108,14 +111,17 @@ services:
container_name: wikidataextractorservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es6c/wikidataextractorservice:latest
profiles: ["dev", "prod"]
build: ./questionsservice/wikidataExtractor
build:
context: ./questionsservice
dockerfile: ./wikidataExtractor/Dockerfile
depends_on:
- mongodb_wiki
ports:
- "8008:8008"
networks:
- mynetwork
environment:
DATAMODELS_URI: './questiondata-model'
MONGODB_URI: mongodb://mongodb_wiki:27017/questions
restart: always

Expand Down
82 changes: 82 additions & 0 deletions questionsservice/questiondata-model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
const mongoose = require('mongoose');

const paisSchema = new mongoose.Schema({
pais: {
type: String,
required: true
},
capital: {
type: String,
required: false
},
continente: {
type: String,
required: false
},
lenguaje: {
type: String,
required: false
},
bandera: {
type: String,
required: false
}
}, { timestamps: {} }); // Añade y gestiona automáticamente los campos createdAt y updatedAt

const monumentSchema = new mongoose.Schema({
monumento: {
type: String,
required: true
},
pais: {
type: String,
required: false
}
}, {timestamps: {}});

const chemicalElementsSchema = new mongoose.Schema({
elemento: {
type: String,
required: true
},
simbolo: {
type: String,
required: false
}
}, {timestamps: {}});

const filmSchema = new mongoose.Schema({
pelicula: {
type: String,
required: true
},
director: {
type: String,
required: false
}
}, {timestamps: {}});

const songSchema = new mongoose.Schema({
cancion: {
type: String,
required: true
},
artista: {
type: String,
required: false
}
}, {timestamps: {}});

const Pais = mongoose.model('Pais', paisSchema);
const Monumento = mongoose.model('Monumento', monumentSchema);
const Elemento = mongoose.model('Elemento', chemicalElementsSchema);
const Pelicula = mongoose.model('Pelicula', filmSchema);
const Cancion = mongoose.model('Cancion', songSchema);

module.exports = {
Pais,
Monumento,
Elemento,
Pelicula,
Cancion
};
5 changes: 3 additions & 2 deletions questionsservice/questiongeneratorservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ FROM node:20
WORKDIR /usr/src/questionsservice/questiongeneratorservice

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
COPY ./questiongeneratorservice/package*.json ./

# Install app dependencies
RUN npm install

# Copy the app source code to the working directory
COPY . .
COPY ./questiongeneratorservice/ .
COPY questiondata-model.js .

# Expose the port the app runs on
EXPOSE 8007
Expand Down
64 changes: 32 additions & 32 deletions questionsservice/questiongeneratorservice/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,18 @@ app.get('/questions', async (req, res) => {
}
} catch (error) {
console.error(`Bad Request: ${error.message}`);
res.status(400).json({ message: error.message });
res.status(400).json({ error: error.message });
}
});

// Route for getting topics for questions
app.get('/topics', async (req, res) => {
try {
const topics = QuestionGenerator.getAvailableTopics();
res.send(topics);
} catch (error) {
console.error(`An error occurred: ${error.message}`);
res.status(500).json({ error: 'Internal Server Error' });
}
});

Expand Down
Loading