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

Develop a propia #103

Merged
merged 20 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ jobs:
- run: npm --prefix webapp ci
- run: npm --prefix users/authservice test -- --coverage
- run: npm --prefix users/userservice test -- --coverage
- run: npm --prefix gameservice test -- --coverage
- run: npm --prefix question_generator test
- run: npm --prefix questionservice test -- --coverage
- run: npm --prefix gameservice test -- --coverage
- run: npm --prefix gatewayservice test -- --coverage
- run: npm --prefix webapp test -- --coverage
- name: Analyze with SonarCloud
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- run: npm --prefix webapp ci
- run: npm --prefix users/authservice test -- --coverage
- run: npm --prefix users/userservice test -- --coverage
- run: npm --prefix question_generator test
- run: npm --prefix questionservice test -- --coverage
- run: npm --prefix gameservice test -- --coverage
- run: npm --prefix gatewayservice test -- --coverage
Expand Down Expand Up @@ -113,7 +114,7 @@ jobs:
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_es3b/question_generator
name: arquisoft/wiq_es3b/questiongenerationservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
Expand Down Expand Up @@ -184,4 +185,4 @@ jobs:
wget https://raw.githubusercontent.com/arquisoft/wiq_es3b/master/docker-compose.yml -O docker-compose.yml
wget https://raw.githubusercontent.com/arquisoft/wiq_es3b/master/.env -O .env
docker compose down
docker compose --profile prod up -d
docker compose --profile prod up -d
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ This repo is a basic application composed of several components.

Both the user and auth service share a Mongo database that is accessed with mongoose.

App Link: http://172.187.201.54:3000/

## Quick start guide

### Using docker
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ services:
- gatewayservice
ports:
- "3000:3000"
environment:
GATEWAY_SERVICE_URL: http://gatewayservice:8000
#volumes:
#- ./webapp:/app

Expand Down
6 changes: 3 additions & 3 deletions question_generator/questionGenerationService.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Question generation service', () => {
expect(response.body).toHaveProperty('question');
expect(response.body).toHaveProperty('correct');
expect(response.body).toHaveProperty('incorrects');
},10000);
},100000);

it('should forward create question request to question generation service', async () => {
const response = await request(app)
Expand All @@ -28,7 +28,7 @@ describe('Question generation service', () => {
expect(response.body).toHaveProperty('question');
expect(response.body).toHaveProperty('correct');
expect(response.body).toHaveProperty('incorrects');
},10000);
},100000);

it('should forward create question request to question generation service', async () => {
const response = await request(app)
Expand All @@ -38,5 +38,5 @@ describe('Question generation service', () => {
expect(response.body).toHaveProperty('question');
expect(response.body).toHaveProperty('correct');
expect(response.body).toHaveProperty('incorrects');
},10000);
},100000);
});
6 changes: 3 additions & 3 deletions question_generator/questionTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ function loadData(){
sportTemplates.loadData()
}
const templates=[
planetsTemplates.getRandomQuestion,
geographyTemplates.getRandomQuestion,
sportTemplates.getRandomQuestion
...Array(1).fill(planetsTemplates.getRandomQuestion),
...Array(4).fill(geographyTemplates.getRandomQuestion),
...Array(4).fill(sportTemplates.getRandomQuestion)

]
module.exports.getRandomQuestion = () => templates[Math.floor(Math.random()*templates.length)]();
Expand Down
9 changes: 7 additions & 2 deletions webapp/src/components/Game.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { PostGame } from './PostGame'
const N_QUESTIONS = 10
const MAX_TIME = 600;

const gatewayUrl=process.env.REACT_APP_API_ENDPOINT||"http://localhost:8000"

const Question = ({ goTo, setGameFinished }) => {

const [question, setQuestion] = useState('');
Expand All @@ -21,7 +23,6 @@ const Question = ({ goTo, setGameFinished }) => {
const [nQuestion, setNQuestion] = useState(0);

const [segundos, setSegundos] = useState(MAX_TIME);

useEffect(() => {

const intervalId = setInterval(() => {
Expand All @@ -32,6 +33,7 @@ const Question = ({ goTo, setGameFinished }) => {
}, 1000);

return () => clearInterval(intervalId);
// eslint-disable-next-line
}, []);

const formatTiempo = (segundos) => {
Expand All @@ -43,7 +45,9 @@ const Question = ({ goTo, setGameFinished }) => {
const fetchQuestion = async () => {

try {
const response = await fetch('http://localhost:8000/api/questions/create');
const response = await fetch(`${gatewayUrl}/api/questions/create`, {
method: 'GET'
});
const data = await response.json();

setQuestion(data.question);
Expand Down Expand Up @@ -116,6 +120,7 @@ const Question = ({ goTo, setGameFinished }) => {

useEffect(() => {
fetchQuestion();
// eslint-disable-next-line
}, []);

return(
Expand Down
Loading