Skip to content

Commit

Permalink
HOTFIX: Cambiado método para rellenar base de datos
Browse files Browse the repository at this point in the history
  • Loading branch information
AbelMH1 committed Apr 12, 2024
1 parent 34f5702 commit 7ba72f0
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions questionsservice/wikidataExtractor/wikidataextractor-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ db.once('open', () => console.log("Connected to MongoDB: %s", mongoUri));
app.use(express.json());

async function extractData() {
var data = await WikiQueries.obtenerPaisYCapital();
var data = await WikiQueries.obtenerPaisYLenguaje();
console.log(data);
var paises = data.map(function (element) {
var p = {
Expand Down Expand Up @@ -53,36 +53,36 @@ cron.schedule(`*/${minutes} * * * *`, () => {
*/

// Route for extracting countries
app.get('/extract', async (req, res) => {
try {
res.json(await extractData());
} catch (error) {
res.status(500).json({ message: error.message })
// res.status(500).json({ error: 'Internal Server Error' });
}
});
// app.get('/extract', async (req, res) => {
// try {
// res.json(await extractData());
// } catch (error) {
// res.status(500).json({ message: error.message })
// // res.status(500).json({ error: 'Internal Server Error' });
// }
// });

// Route for geting countries
app.get('/countries', async (req, res) => {
try {
const paises = await Pais.find({})
res.json(paises);
} catch (error) {
res.status(500).json({ message: error.message })
// res.status(500).json({ error: 'Internal Server Error' });
}
});
// // Route for geting countries
// app.get('/countries', async (req, res) => {
// try {
// const paises = await Pais.find({})
// res.json(paises);
// } catch (error) {
// res.status(500).json({ message: error.message })
// // res.status(500).json({ error: 'Internal Server Error' });
// }
// });

// Route for deleting countries
app.delete('/countries', async (req, res) => {
try {
const paises = await Pais.deleteMany({})
res.json(paises);
} catch (error) {
res.status(500).json({ message: error.message })
// res.status(500).json({ error: 'Internal Server Error' });
}
});
// // Route for deleting countries
// app.delete('/countries', async (req, res) => {
// try {
// const paises = await Pais.deleteMany({})
// res.json(paises);
// } catch (error) {
// res.status(500).json({ message: error.message })
// // res.status(500).json({ error: 'Internal Server Error' });
// }
// });


app.use((err, req, res, next) => {
Expand Down

0 comments on commit 7ba72f0

Please sign in to comment.