production readme - RobertVogue/Passport GitHub Wiki
Passports Global is a web application where users can go to keep track of all of their global travels.
- JavaScript
- Pug
- CSS
- Heroku
https://passport-global.herokuapp.com/
https://github.com/RobertVogue/Passport/wiki
- The stamp creation feature
- Writing complex queries
Thankfully we faced very few challenges in our group dynamics. We faced the standard code bugs which we worked together to solve. We had pages break without our understanding why, but we were able to fix or rebuild where necessary. We were able to successfully create complex queries and link them to complex routes. Each challenge we faced, we approached as a group and worked together to solve.
- Routes logic to get top 3 countries that people want to visit
router.get('/', csrfProtection, asyncHandler(async (req, res) => {
const wantToVisit = await topWantToVisit();
const visited = await topVisited();
const nearby = await topNearBy();
res.render('index', { csrfToken: req.csrfToken(), wantToVisit, visited, nearby });
}));
const topNearBy = async () => {
const topCountries = await Stamp.findAll({
where: { rating: 5 },
include: [{
model: Passport,
where: { passport_status: "Near By" },
},
{
model: Country
}
],
});
const countryObj = {};
const countryNames = topCountries.map(data => {
return data.Country.dataValues.name
});
countryNames.forEach(country => {
if (countryObj[country]) {
countryObj[country]++;
} else {
countryObj[country] = 1;
};
});
let countriesArr = Object.entries(countryObj).sort((a, b) => b[1] - a[1]).map(el => el[0])
return countriesArr.splice(0, 10);
}