Skip to content

Commit

Permalink
Merge pull request #98 from Arquisoft/carlos
Browse files Browse the repository at this point in the history
Documentación, filtro de peticiones y post cambiados por gets
  • Loading branch information
baraganio authored Apr 7, 2024
2 parents f2f4236 + 668b401 commit 881154f
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 77 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,6 @@ jobs:
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Update OpenAPI configuration
run: |
DEPLOY_HOST=${{ secrets.DEPLOY_HOST }}
sed -i "s/SOMEIP/${DEPLOY_HOST}/g" gatewayservice/openapi.yaml
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
Expand All @@ -167,6 +163,4 @@ jobs:
wget https://raw.githubusercontent.com/arquisoft/wiq_es2b/master/docker-compose.yml -O docker-compose.yml
wget https://raw.githubusercontent.com/arquisoft/wiq_es2b/master/.env -O .env
docker compose --profile prod down
docker compose --profile prod up -d --pull always
docker compose --profile prod up -d --pull always
80 changes: 22 additions & 58 deletions docs/src/06_runtime_view.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,63 +3,27 @@ ifndef::imagesdir[:imagesdir: ../images]
[[section-runtime-view]]
== Runtime View


[role="arc42help"]
****
.Contents
The runtime view describes concrete behavior and interactions of the system’s building blocks in form of scenarios from the following areas:
* important use cases or features: how do building blocks execute them?
* interactions at critical external interfaces: how do building blocks cooperate with users and neighboring systems?
* operation and administration: launch, start-up, stop
* error and exception scenarios
Remark: The main criterion for the choice of possible scenarios (sequences, workflows) is their *architectural relevance*. It is *not* important to describe a large number of scenarios. You should rather document a representative selection.
.Motivation
You should understand how (instances of) building blocks of your system perform their job and communicate at runtime.
You will mainly capture scenarios in your documentation to communicate your architecture to stakeholders that are less willing or able to read and understand the static models (building block view, deployment view).
.Form
There are many notations for describing scenarios, e.g.
* numbered list of steps (in natural language)
* activity diagrams or flow charts
* sequence diagrams
* BPMN or EPCs (event process chains)
* state machines
* ...
.Further Information
See https://docs.arc42.org/section-6/[Runtime View] in the arc42 documentation.
****

=== <Runtime Scenario 1>


* _<insert runtime diagram or textual description of the scenario>_
* _<insert description of the notable aspects of the interactions between the
building block instances depicted in this diagram.>_

It is possible to use a sequence diagram:

[plantuml,"Sequence diagram",png]
=== User plays a game
When the game is started, the app will call the createquestion service that is in charge of provide generated questions from wikidata information.
[plantuml,"Start a game",png]
----
actor Alice
actor Bob
database Pod as "Bob's Pod"
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
Alice --> Pod: Store route
Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response
actor a as "User"
participant q as "Game GUI"
participant w as "CreateQuestions service"
database d as "Database"
a -> q: Start the game
loop number of questions
q -> w: Ask for a question
w -->q: Returns the question
q -> d: Store the question
q -> a: Returns the question
a -> q: Pick an answer
q -> a: Shows if the answer was valid or not
a -> q: Asks for next question
end
q -> a: Show the game stats
q -> d: Store the game with questions, answers and stats
----

=== <Runtime Scenario 2>

=== ...

=== <Runtime Scenario n>
8 changes: 4 additions & 4 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,21 @@ app.get('/getgamehistory/:username', async (req, res) => {



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

app.post('/getquestionshistory', async (req, res) => {
app.get('/getquestionshistory', async (req, res) => {
try {
// Create a petition to the URL (le llegará a retrieve-service.js) with the option /getgeneratedquestions and the req.body params
const questionResponse = await axios.post(retrieveServiceUrl+'/getquestionshistory', req.body);
const questionResponse = await axios.get(retrieveServiceUrl+'/getquestionshistory', req.body);
// Return a json response with what we obtained on the petition
res.json(questionResponse.data);
} catch (error) {
Expand Down
14 changes: 9 additions & 5 deletions questions/creationservice/creation-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ function getQuestionInfo(info){

// Select 4 random rows of the data
for (let i = 0; i<optionsNumber; i++){
var indexRow = Math.floor(Math.random() * numEles);
fourRows.push(info[indexRow]);
// Store the 4 posible answers
answerOptions.push(info[indexRow].answerLabel.value);
let indexRow = Math.floor(Math.random() * numEles);
if(info[indexRow].answerLabel.value.charAt(0)=='Q' || info[indexRow].questionObjectLabel.value.charAt(0)=='Q'){
i = i - 1;
}else{
fourRows.push(info[indexRow]);
// Store the 4 posible answers
answerOptions.push(info[indexRow].answerLabel.value);
}
}

// Select the row where it will extract the country and capital
Expand Down Expand Up @@ -73,7 +77,7 @@ async function saveQuestion(){
}
}

app.post('/createquestion', async (req, res) => {
app.get('/createquestion', async (req, res) => {
selectRandomQuery();
const apiUrl = `https://query.wikidata.org/sparql?query=${encodeURIComponent(queries[randomQuerySelector])}&format=json`;

Expand Down
2 changes: 1 addition & 1 deletion questions/retrieveservice/retrieve-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/questiond
mongoose.connect(mongoUri);


app.post('/getquestionshistory', async (req, res) => {
app.get('/getquestionshistory', async (req, res) => {
const questions = await Question.find({});

var solution = [];
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/components/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const Game = () => {
const handleShowQuestion = async () => {
try{
// It makes a petition to the api and store the response
const response = await axios.post(`${apiEndpoint}/createquestion`, { });
const response = await axios.get(`${apiEndpoint}/createquestion`, { });
// Extract all the info of the response and store it
setQuestionObject(response.data.responseQuestionObject);
setCorrectOption(response.data.responseCorrectOption);
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/components/HistoricalData.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const HistoricalData = () => {
const handleShowHistory = async () => {
try{
// It makes a petition to the api and store the response
const response = await axios.post(`${apiEndpoint}/getquestionshistory`, { });
const response = await axios.get(`${apiEndpoint}/getquestionshistory`, { });
setQuestionsHistory(response.data);
}catch (error){
console.error('Error:', error);
Expand Down

0 comments on commit 881154f

Please sign in to comment.