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

Añado cambios de sacar datos de la Base de Datos #58

Merged
merged 18 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
158 changes: 158 additions & 0 deletions WikidataPrueba/consultas.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
--CONSULTAS GEOGRAFIA --
--Consulta que devuelve pais y capital --

SELECT ?country ?countryLabel ?capitalLabel
WHERE
{
?country wdt:P31 wd:Q3624078. # Instance of country
?country wdt:P36 ?capital. # Has capital
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}


--Consulta que devuelve pais y poblacion --
SELECT ?country ?countryLabel ?population
WHERE
{
?country wdt:P31 wd:Q3624078. # Instance of country
?country wdt:P1082 ?population. # Has population
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

--Consulta que devuelve pais, capital y poblacion --
SELECT ?country ?countryLabel ?capitalLabel ?population
WHERE
{
?country wdt:P31 wd:Q3624078. # Instance of country
?country wdt:P36 ?capital. # Has capital
?country wdt:P1082 ?population. # Has population
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

--Consulta estado de EEUU y su capital --
SELECT ?state ?stateLabel ?capitalLabel
WHERE {
?state wdt:P31 wd:Q35657 .
?state p:P36 ?statement .
?statement ps:P36 ?capital .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}


--Consulta estados de EEUU, capital y poblacion
SELECT ?state ?stateLabel ?capitalLabel ?poblation
WHERE {
?state wdt:P31 wd:Q35657 .
?state wdt:P36 ?capital .
?state wdt:P1082 ?poblation .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".}
}


--CONSULTAS DEPORTES--
--Consulta que devuelve club de futbol y su estadio --

SELECT ?club ?clubLabel ?stadiumLabel
WHERE {
?club wdt:P31 wd:Q17270000 .
?club p:P115 ?statement .
?statement ps:P115 ?stadium .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}


--CONSULTAS ARTE---
--Consulta libro y su autor --
SELECT ?book ?bookLabel ?authorLabel
WHERE {
?book wdt:P31 wd:Q571 .
?book wdt:P50 ?author .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".}
}


--Consulta que devuelve libre y su autor pero solo 4 resultados --

SELECT ?book ?bookLabel ?authorLabel
WHERE {
?book wdt:P31 wd:Q571 .
?book wdt:P50 ?author .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".}
}
LIMIT 4

--Consulta que me da peliculas su genero y año de publicacion del director Steven Spielberg --

SELECT ?film ?filmLabel ?genere ?d WHERE {
{
SELECT ?film (GROUP_CONCAT(DISTINCT ?gL; SEPARATOR = ", ") AS ?genere) (MIN(YEAR(?date)) AS ?d) WHERE {
?sitelink schema:about ?director;
schema:isPartOf <https://en.wikipedia.org/>;
schema:name "Steven Spielberg"@en. # Edit this with different director's name to see their films. Use the English Wikipedia title only.
?film wdt:P31 wd:Q11424;
wdt:P136 ?g, ?g.
?g rdfs:label ?gL.
?film wdt:P57 ?director;
wdt:P577 ?date.
FILTER((LANG(?gL)) = "en")
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
GROUP BY ?film
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}

--CONSULTAS ENTRETENIMIENTO--
# Consulta para obtener videojuegos y sus plataformas de desarrollo
SELECT ?videojuego ?nombreVideojuego ?plataforma ?nombrePlataforma
WHERE {
?videojuego wdt:P31 wd:Q7889. # Videojuegos (clase)
?videojuego wdt:P178 ?plataforma. # Relación "desarrollado para"
?videojuego rdfs:label ?nombreVideojuego filter (lang(?nombreVideojuego) = "es").
?plataforma rdfs:label ?nombrePlataforma filter (lang(?nombrePlataforma) = "es").
}
LIMIT 100


# Consulta para obtener el nombre del videojuego y su género
SELECT ?videojuego ?nombreVideojuego ?genero ?nombreGenero
WHERE {
?videojuego wdt:P31 wd:Q7889. # Videojuegos (clase)
?videojuego wdt:P136 ?genero. # Relación "género"
?videojuego rdfs:label ?nombreVideojuego filter (lang(?nombreVideojuego) = "es").
?genero rdfs:label ?nombreGenero filter (lang(?nombreGenero) = "es").
}
LIMIT 100


--CONSULTAS CIENCIA--

--CONSULTAS HISTORIA--


--OTRAS CONSULTAS--


--Consulta que me devuelve por orden descendente y solo 4 resultados las ciudades mas grandes por pais
me devuelve el nombre de la ciudad, pais y poblacion --

SELECT DISTINCT ?city ?cityLabel ?population ?countryLabel WHERE {
{
SELECT (MAX(?population_) AS ?population) ?country WHERE {
?city wdt:P31/wdt:P279* wd:Q515 .
?city wdt:P1082 ?population_ .
?city wdt:P17 ?country .
}
GROUP BY ?country
ORDER BY DESC(?population)
}
?city wdt:P31/wdt:P279* wd:Q515 .
?city wdt:P1082 ?population .
?city wdt:P17 ?country .
?city wdt:P625 ?loc .
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
ORDER BY DESC(?population)
LIMIT 4
Binary file added docs/images/3.BusinessContext.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 added docs/images/Business Context.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 added docs/images/Sin título.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 8 additions & 59 deletions docs/src/03_system_scope_and_context.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,75 +4,24 @@ ifndef::imagesdir[:imagesdir: ../images]
== System Scope and Context


[role="arc42help"]
****
.Contents
System scope and context - as the name suggests - delimits your system (i.e. your scope) from all its communication partners
(neighboring systems and users, i.e. the context of your system). It thereby specifies the external interfaces.

If necessary, differentiate the business context (domain specific inputs and outputs) from the technical context (channels, protocols, hardware).

.Motivation
The domain interfaces and technical interfaces to communication partners are among your system's most critical aspects. Make sure that you completely understand them.

.Form
Various options:

* Context diagrams
* Lists of communication partners and their interfaces.


.Further Information

See https://docs.arc42.org/section-3/[Context and Scope] in the arc42 documentation.

****


=== Business Context

[role="arc42help"]
****
.Contents
Specification of *all* communication partners (users, IT-systems, ...) with explanations of domain specific inputs and outputs or interfaces.
Optionally you can add domain specific formats or communication protocols.

.Motivation
All stakeholders should understand which data are exchanged with the environment of the system.

.Form
All kinds of diagrams that show the system as a black box and specify the domain interfaces to communication partners.

Alternatively (or additionally) you can use a table.
The title of the table is the name of your system, the three columns contain the name of the communication partner, the inputs, and the outputs.

****
In our business setting, we have developed a web application called WIQ, where users engage in a question-based game.
This application draws inspiration from the renowned Spanish television program "Saber y Ganar," providing users with an interactive and entertaining experience.



image::Business Context.png["Business Context Diagram"]
[options="header",cols="1,2"]
|===
|Element |Description
|User |
|Application |
|WikiData |
|===
* Users authenticate themselves within the system using their personal information.
* The application offers a question-based game similar to "Saber y Ganar" .
* The primary objective of the project is to provide an interactive and enjoyable platform for users to engage in question and answer contests, promoting both entertainment and learning.
* Users have access to various metrics regarding their participation, including the number of games played, correct and incorrect answers, and time spent on each question.


=== Technical Context

[role="arc42help"]
****
.Contents
Technical interfaces (channels and transmission media) linking your system to its environment. In addition a mapping of domain specific input/output to the channels, i.e. an explanation which I/O uses which channel.

.Motivation
Many stakeholders make architectural decision based on the technical interfaces between the system and its context. Especially infrastructure or hardware designers decide these technical interfaces.

.Form
E.g. UML deployment diagram describing channels to neighboring systems,
together with a mapping table showing the relationships between channels and input/output.

****

[options="header",cols="1,2"]
|===
Expand Down
67 changes: 6 additions & 61 deletions docs/src/08_concepts.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,16 @@ ifndef::imagesdir[:imagesdir: ../images]


[role="arc42help"]
****
.Content
This section describes overall, principal regulations and solution ideas that are relevant in multiple parts (= cross-cutting) of your system.
Such concepts are often related to multiple building blocks.
They can include many different topics, such as

* models, especially domain models
* architecture or design patterns
* rules for using specific technology
* principal, often technical decisions of an overarching (= cross-cutting) nature
* implementation rules


.Motivation
Concepts form the basis for _conceptual integrity_ (consistency, homogeneity) of the architecture.
Thus, they are an important contribution to achieve inner qualities of your system.

Some of these concepts cannot be assigned to individual building blocks, e.g. security or safety.


.Form
The form can be varied:

* concept papers with any kind of structure
* cross-cutting model excerpts or scenarios using notations of the architecture views
* sample implementations, especially for technical concepts
* reference to typical usage of standard frameworks (e.g. using Hibernate for object/relational mapping)

.Structure
A potential (but not mandatory) structure for this section could be:

* Domain concepts
* User Experience concepts (UX)
* Safety and security concepts
* Architecture and design patterns
* "Under-the-hood"
* development concepts
* operational concepts

Note: it might be difficult to assign individual concepts to one specific topic
on this list.

image::08-Crosscutting-Concepts-Structure-EN.png["Possible topics for crosscutting concepts"]


.Further Information

See https://docs.arc42.org/section-8/[Concepts] in the arc42 documentation.
****


=== Domain concepts
User Model
- ID (Primary Key)
- First Name
- Last Name
- Email
- Password
- Role
- ID (Primary Key)
- First Name
- Last Name
- Email
- Password


=== User Experience
Expand All @@ -84,9 +35,6 @@ Additionally, they can start a new game at any time and, upon completion, view t
=== Architecture and design patterns
In development...

=== Under the hood
In development...


=== Development concepts

Expand All @@ -96,9 +44,6 @@ In development...
* Configurability





=== Operation concepts

In development...

51 changes: 51 additions & 0 deletions questionsService/obtenerPreguntasBaseDatos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const mongoose = require('mongoose');
class ObtenerPreguntas{

obtenerPregunta(){
// Connect to MongoDB
const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/questionsdb';
mongoose.connect(mongoUri);

var pregunta;
var respuestaCorrecta;
var respuestaIncorrecta1;
var respuestaIncorrecta2;
var respuestaIncorrecta3;

Pregunta.aggregate([
{ $sample: { size: 1 } }
]).then(pregunta => {
var pregunta_id = pregunta._id;
pregunta = pregunta.textoPregunta;
Tipo.findOne({ _id: { $in: pregunta.pregunta_id } }).then(tipo => {
console.log(tipo_id);
respuestaCorrecta = pregunta.respuestaCorrecta;
console.log(respuestaCorrecta);
Respuesta.aggregate([
{ $match: { nombreTipo: tipo._id, texto: { $ne: [respuestaCorrecta, "Ninguna de las anteriores" ]} } },
{ $sample: { size: 3 } }

]).then(respuestas => {
console.log(respuestas);
respuestaIncorrecta1 = respuestas[0].textoRespuesta;
respuestaIncorrecta2 = respuestas[1].textoRespuesta;
respuestaIncorrecta3 = respuestas[2].textoRespuesta;
}).catch(err => {
console.error(err);
});
})
console.log(pregunta_id);

}).catch(err => {
console.error(err);
});

return resultado = {
pregunta: pregunta.textoPregunta,
correcta: respuestaCorrecta,
respuestasIncorrecta1: respuestaIncorrecta1,
respuestasIncorrecta2: respuestaIncorrecta2,
respuestasIncorrecta3: respuestaIncorrecta3
};
}
}