Skip to content

Commit 37b2578

Browse files
committed
Merge branch 'ui_enchancements' of https://github.com/Arquisoft/wiq_en3a into front_end_angel and format fix, visual enhancements, stats improvement
2 parents fa1c777 + 82c2c0b commit 37b2578

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1250
-163
lines changed

.github/workflows/release.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ jobs:
4141
with:
4242
node-version: 20
4343
- run: npm --prefix wikidataservice install
44-
- run: npm --prefix users/authservice install
45-
- run: npm --prefix users/userservice install
44+
- run: npm --prefix users install
4645
- run: npm --prefix gatewayservice install
4746
- run: npm --prefix webapp install
4847
- run: npm --prefix webapp run build
@@ -109,7 +108,7 @@ jobs:
109108
deploy:
110109
name: Deploy over SSH
111110
runs-on: ubuntu-latest
112-
needs: [docker-push-gatewayservice,docker-push-webapp, docker-push-users, docker-push-wikidataservice]
111+
needs: [docker-push-gatewayservice, docker-push-webapp, docker-push-users, docker-push-wikidataservice]
113112
steps:
114113
- name: Deploy over SSH
115114
uses: fifsky/ssh-action@master

gatewayservice/gateway-service.js

+22-3
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,20 @@ app.post('/adduser', async (req, res) => {
4646
}
4747
});
4848

49-
app.post('/edituser', async (req, res) => {
49+
app.post('/sumNormalStats', async (req, res) => {
5050
try {
51-
// Forward the edit user request to the user service
52-
const userResponse = await axios.post(userServiceUrl + '/user/edituser', req.body);
51+
// Forward the edit user with normal stats request to the user service
52+
const userResponse = await axios.post(userServiceUrl + '/user/sumNormalStats', req.body);
53+
res.json(userResponse.data);
54+
} catch (error) {
55+
console.error(error);
56+
}
57+
});
58+
59+
app.post('/sumTrivialStats', async (req, res) => {
60+
try {
61+
// Forward the edit user with trivial stats request to the user service
62+
const userResponse = await axios.post(userServiceUrl + '/user/sumTrivialStats', req.body);
5363
res.json(userResponse.data);
5464
} catch (error) {
5565
console.error(error);
@@ -67,6 +77,15 @@ app.get('/getAllUsers', async (req, res) => {
6777
}
6878
});
6979

80+
app.post('/getUser', async (req, res) => {
81+
try {
82+
const usersResponse = await axios.get(userServiceUrl + '/user/getUser', req.body);
83+
res.json(usersResponse.data);
84+
} catch (error) {
85+
console.error(error);
86+
}
87+
});
88+
7089

7190
app.get('/GetQuestions', async (_req, res) => {
7291
try {

gatewayservice/gateway-service.test.js

+42-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ afterAll(() => {
1111
describe('Gateway Service', () => {
1212

1313
axios.get.mockImplementation((url) => {
14-
if (url.endsWith('Questions')) {
14+
if (url.endsWith('getQuestions') || url.endsWith('getCapitalsQuestions')
15+
|| url.endsWith('getMovieDirectorsQuestions') || url.endsWith('getElementSymbolsQuestions')) {
1516
return Promise.resolve({
1617
status: 200,
1718
data: {
@@ -68,7 +69,20 @@ describe('Gateway Service', () => {
6869
}],
6970
}
7071
});
71-
}
72+
} else if(url.endsWith('Questions')){
73+
return Promise.resolve({
74+
status: 200,
75+
data: {
76+
questions: [
77+
{
78+
"text": "What is the capital of France?",
79+
"answers": ["London", "Berlin", "Paris", "Madrid"],
80+
"correctAnswer": 2
81+
}
82+
],
83+
}
84+
});
85+
}
7286

7387

7488
return Promise.resolve({
@@ -141,9 +155,34 @@ describe('Gateway Service', () => {
141155
});
142156

143157
it('should retrieve 10 movie directors questions with their corresponding answers', async () => {
144-
await checkCorrectQuestionsResponse('/getMovieDirectorsQuestions', 10);
158+
await checkCorrectQuestionsResponse('/GetMovieDirectorsQuestions', 10);
145159
});
146160

161+
it('should retrieve 1 history question with its corresponding answer', async () => {
162+
163+
await checkCorrectQuestionsResponse('/GetHistoryQuestions', 1);
164+
}, 60000);
165+
166+
it('should retrieve 1 sports-related question with its corresponding answer', async () => {
167+
168+
await checkCorrectQuestionsResponse('/GetSportQuestions', 1);
169+
}, 60000);
170+
171+
it('should retrieve 1 geography question with its corresponding answer', async () => {
172+
173+
await checkCorrectQuestionsResponse('/GetGeographyQuestions', 1);
174+
}, 60000);
175+
176+
it('should retrieve 1 geography question with its corresponding answer', async () => {
177+
178+
await checkCorrectQuestionsResponse('/GetEntertainmentQuestions', 1);
179+
}, 60000);
180+
181+
it('should retrieve 1 geography question with its corresponding answer', async () => {
182+
183+
await checkCorrectQuestionsResponse('/GetChemistryQuestions', 1);
184+
}, 60000);
185+
147186

148187
async function checkCorrectQuestionsResponse(endpoint, retrieved){
149188
const response = await request(app).get(endpoint);

0 commit comments

Comments
 (0)