Skip to content

Commit

Permalink
Merge pull request #8 from dataesr/fixInfluence
Browse files Browse the repository at this point in the history
total must have all country code. Even ZOE, ZOI
  • Loading branch information
jerem1508 authored Mar 8, 2024
2 parents 66fef5e + b7fdc72 commit b6a6789
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions server/src/routes/tableaux/european-projects/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ router.route('/european-projects/analysis-positioning-top-10-beneficiaries')
.get(async (req, res) => {
const data = await db.collection('EP-fr-esr-all-projects-entities')
.aggregate([
{ $match: { framework: "Horizon Europe", country_code: { $nin: ["ZOE", "ZOI"] } } },
{ $match: { framework: "Horizon Europe" } },
{
$group: {
_id: {
Expand All @@ -533,13 +533,15 @@ router.route('/european-projects/analysis-positioning-top-10-beneficiaries')
const total_fund_eur = data.reduce((acc, el) => acc + el.total_fund_eur, 0);
const dataReturn = {
total_fund_eur,
top10: data.slice(0, 10).map((el) => {
acc += el.total_fund_eur;
return {
...el,
influence: acc / total_fund_eur * 100,
top10: data.map((el) => {
if (el.id !== 'ZOE' && el.id !== 'ZOI') {
acc += el.total_fund_eur;
return {
...el,
influence: acc / total_fund_eur * 100,
}
}
})
}).filter((el) => el).slice(0, 10)
}

return res.json(dataReturn)
Expand Down

0 comments on commit b6a6789

Please sign in to comment.