diff --git a/client/src/pages/european-projects/charts-config.json b/client/src/pages/european-projects/charts-config.json
index f0d267b4..cd597fe3 100644
--- a/client/src/pages/european-projects/charts-config.json
+++ b/client/src/pages/european-projects/charts-config.json
@@ -42,6 +42,15 @@
"sourceURL": "https://cordis.europa.eu/",
"integrationURL": "/european-projects/components/pages/analysis/overview/charts/projects-types-2"
},
+ {
+ "id": "successRateForAmountsByPillar",
+ "title": "",
+ "subtitle": "Taux de succès sur le montants par pilier",
+ "description": "Attention EIT",
+ "source": "Commission européenne, Cordis",
+ "sourceURL": "https://cordis.europa.eu/",
+ "integrationURL": "/european-projects/components/pages/analysis/overview/charts/projects-types-2"
+ },
{
"id": "projectsTypesPiliers1",
"title": "",
diff --git a/client/src/pages/european-projects/components/pages/general/overview/charts/projects-types-2/query.tsx b/client/src/pages/european-projects/components/pages/general/overview/charts/projects-types-2/query.tsx
index 69df4e83..cbfd00ab 100644
--- a/client/src/pages/european-projects/components/pages/general/overview/charts/projects-types-2/query.tsx
+++ b/client/src/pages/european-projects/components/pages/general/overview/charts/projects-types-2/query.tsx
@@ -1,11 +1,10 @@
const { VITE_APP_SERVER_URL } = import.meta.env;
export async function GetData(params: string) {
- let url = `${VITE_APP_SERVER_URL}/european-projects/analysis-synthese-projects-types-2`;
- if (params !== '') {
- url = `${VITE_APP_SERVER_URL}/european-projects/analysis-synthese-projects-types-2?${params}`;
+ let url = `${VITE_APP_SERVER_URL}/european-projects/general-ProjectsTypes-SuccessRateForAmountsByProjectsTypes`;
+ if (params !== "") {
+ url = `${VITE_APP_SERVER_URL}/european-projects/general-ProjectsTypes-SuccessRateForAmountsByProjectsTypes?${params}`;
}
- return fetch(url).then((response) => (response.json()))
+ return fetch(url).then((response) => response.json());
}
-
diff --git a/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-pillar/index.tsx b/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-pillar/index.tsx
new file mode 100644
index 00000000..f645ebf7
--- /dev/null
+++ b/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-pillar/index.tsx
@@ -0,0 +1,72 @@
+import { useQuery } from "@tanstack/react-query";
+import { useSearchParams } from "react-router-dom";
+
+import Template from "./template";
+import { GetData } from "./query";
+import options from "./options";
+
+import ChartWrapper from "../../../../../chart-wrapper";
+import { getDefaultParams } from "./utils";
+import { Col, Container, Row } from "@dataesr/dsfr-plus";
+
+export default function SuccessRateForAmountsByPillar() {
+ const [searchParams] = useSearchParams();
+ const params = getDefaultParams(searchParams);
+
+ const { data, isLoading } = useQuery({
+ queryKey: ["successRateForAmountsByPillar", params],
+ queryFn: () => GetData(params),
+ });
+
+ if (isLoading || !data) return ;
+ return (
+
+
+
+
+
+
+ Pays sélectionné
+
+
+
+ UE & Etats associés
+
+
+ }
+ />
+
+
+
+ );
+}
diff --git a/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-pillar/options.tsx b/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-pillar/options.tsx
new file mode 100644
index 00000000..bb0793b4
--- /dev/null
+++ b/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-pillar/options.tsx
@@ -0,0 +1,66 @@
+export default function Options(data) {
+ if (!data) return null;
+
+ // sort selectedCountry by action_id
+ const selectedCountry = data.selectedCountry
+ .filter((el) => el.ratio && el.ratio !== 0)
+ .sort((a, b) => a.id - b.id);
+
+ // sort otherCountries same as selectedCountry
+ data.otherCountries.sort((a, b) => {
+ return (
+ data.selectedCountry.findIndex((item) => item.id === a.id) -
+ data.selectedCountry.findIndex((item) => item.id === b.id)
+ );
+ });
+
+ const otherCountriesSorted = selectedCountry.map((item) => {
+ return data.otherCountries.find((otherItem) => otherItem.id === item.id);
+ });
+
+ return {
+ chart: {
+ type: "column",
+ height: 500,
+ backgroundColor: "transparent",
+ },
+ title: { text: "" },
+ legend: { enabled: false },
+ credits: { enabled: false },
+
+ xAxis: {
+ categories: selectedCountry.map((item) => item.id),
+ crosshair: true,
+ accessibility: {
+ description: "Actions",
+ },
+ },
+ yAxis: {
+ min: 0,
+ title: {
+ text: "(%)",
+ },
+ },
+ tooltip: {
+ valueSuffix: " (%)",
+ },
+ plotOptions: {
+ column: {
+ pointPadding: 0.2,
+ borderWidth: 0,
+ },
+ },
+ series: [
+ {
+ name: "Pays",
+ data: selectedCountry.map((item) => item.ratio),
+ color: "#6DD897",
+ },
+ {
+ name: "UE & Etats associés",
+ data: otherCountriesSorted.map((item) => item.ratio),
+ color: "#09622A",
+ },
+ ],
+ };
+}
diff --git a/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-pillar/query.tsx b/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-pillar/query.tsx
new file mode 100644
index 00000000..f00faa2a
--- /dev/null
+++ b/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-pillar/query.tsx
@@ -0,0 +1,10 @@
+const { VITE_APP_SERVER_URL } = import.meta.env;
+
+export async function GetData(params: string) {
+ let url = `${VITE_APP_SERVER_URL}/european-projects/general-projectsTypes-successRateForAmountsByPillar`;
+ if (params !== "") {
+ url = `${VITE_APP_SERVER_URL}/european-projects/general-projectsTypes-successRateForAmountsByPillar?${params}`;
+ }
+
+ return fetch(url).then((response) => response.json());
+}
diff --git a/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-pillar/template.tsx b/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-pillar/template.tsx
new file mode 100644
index 00000000..035d7d52
--- /dev/null
+++ b/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-pillar/template.tsx
@@ -0,0 +1,7 @@
+export default function Template() {
+ return (
+ <>
+ graph template
+ >
+ );
+}
\ No newline at end of file
diff --git a/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-pillar/utils.tsx b/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-pillar/utils.tsx
new file mode 100644
index 00000000..32137f2f
--- /dev/null
+++ b/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-pillar/utils.tsx
@@ -0,0 +1,5 @@
+export function getDefaultParams(searchParams) {
+ const params = [...searchParams].map(([key, value]) => `${key}=${value}`).join('&');
+
+ return params + '&stage=successful';
+}
\ No newline at end of file
diff --git a/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-type-of-financing/index.tsx b/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-type-of-financing/index.tsx
index 697fbf1d..5d14c30a 100644
--- a/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-type-of-financing/index.tsx
+++ b/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-type-of-financing/index.tsx
@@ -13,7 +13,7 @@ export default function SuccessRateForAmountsByTypeOfFinancing() {
const params = getDefaultParams(searchParams);
const { data, isLoading } = useQuery({
- queryKey: ["projectsTypes2", params],
+ queryKey: ["SuccessRateForAmountsByProjectsTypes", params],
queryFn: () => GetData(params),
});
diff --git a/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-type-of-financing/query.tsx b/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-type-of-financing/query.tsx
index 69df4e83..5b393175 100644
--- a/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-type-of-financing/query.tsx
+++ b/client/src/pages/european-projects/components/pages/general/projects-types/charts/success-rate-for-amounts-by-type-of-financing/query.tsx
@@ -1,11 +1,10 @@
const { VITE_APP_SERVER_URL } = import.meta.env;
export async function GetData(params: string) {
- let url = `${VITE_APP_SERVER_URL}/european-projects/analysis-synthese-projects-types-2`;
- if (params !== '') {
- url = `${VITE_APP_SERVER_URL}/european-projects/analysis-synthese-projects-types-2?${params}`;
+ let url = `${VITE_APP_SERVER_URL}/european-projects/general-projectsTypes-successRateForAmountsByProjectsTypes`;
+ if (params !== "") {
+ url = `${VITE_APP_SERVER_URL}/european-projects/general-projectsTypes-successRateForAmountsByProjectsTypes?${params}`;
}
- return fetch(url).then((response) => (response.json()))
+ return fetch(url).then((response) => response.json());
}
-
diff --git a/client/src/pages/european-projects/components/pages/general/projects-types/index.tsx b/client/src/pages/european-projects/components/pages/general/projects-types/index.tsx
index 83735d2c..651652cd 100644
--- a/client/src/pages/european-projects/components/pages/general/projects-types/index.tsx
+++ b/client/src/pages/european-projects/components/pages/general/projects-types/index.tsx
@@ -6,6 +6,7 @@ import ProjectsTypesPiliers1 from "./charts/projects-types-piliers-1";
import ProjectsTypes1 from "./charts/projects-types-1";
import SuccessRateForAmountsByTypeOfFinancing from "./charts/success-rate-for-amounts-by-type-of-financing";
import ProjectsTypesPillarsSubsidiesRequested from "./charts/projects-types-pillars-subsidies-requested";
+import SuccessRateForAmountsByPillar from "./charts/success-rate-for-amounts-by-pillar";
export default function ProjectsTypes() {
const [searchParams, setSearchParams] = useSearchParams();
@@ -25,6 +26,9 @@ export default function ProjectsTypes() {
+
+
+
Par type de projets
diff --git a/server/src/routes/tableaux/european-projects/index.js b/server/src/routes/tableaux/european-projects/index.js
index 90d3bfd6..14058ffd 100644
--- a/server/src/routes/tableaux/european-projects/index.js
+++ b/server/src/routes/tableaux/european-projects/index.js
@@ -333,7 +333,9 @@ router
});
router
- .route("/european-projects/analysis-synthese-projects-types-2")
+ .route(
+ "/european-projects/general-projectsTypes-successRateForAmountsByProjectsTypes"
+ )
.get(async (req, res) => {
if (!req.query.country_code) {
res.status(400).send("country_code is required");
@@ -458,66 +460,157 @@ router
])
.toArray();
- // const data = await db.collection('fr-esr-all-projects-synthese')
- // .aggregate([
- // { $match: { country_association_code: "MEMBER-ASSOCIATED" } },
- // {
- // $group: {
- // _id: {
- // stage: "$stage",
- // action_id: "$action_id",
- // action_name: "$action_name",
- // country_code: "$country_code",
- // country_association_code: "$country_association_code",
- // },
- // total_fund_eur: { $sum: "$fund_eur" },
- // },
- // },
- // {
- // $project: {
- // _id: 0,
- // stage: "$_id.stage",
- // total_fund_eur: 1,
- // action_id: "$_id.action_id",
- // action_name: "$_id.action_name",
- // country_code: "$_id.country_code",
- // country_association_code: "$_id.country_association_code",
- // }
- // },
- // {
- // $group: {
- // _id: null,
- // selectedCountry: {
- // $push: { $cond: [{ $eq: ["$country_code", req.query.country_code] }, "$$ROOT", null] }
- // },
- // otherCountries: {
- // $push: { $cond: [{ $ne: ["$country_code", req.query.country_code] }, "$$ROOT", null] }
- // },
- // },
- // },
- // {
- // $project: {
- // _id: 0,
- // selectedCountry: {
- // $filter:
- // {
- // input: "$selectedCountry",
- // as: "selectedCountryFiltered",
- // cond: { $ne: ["$$selectedCountryFiltered", null] },
+ const data = {
+ selectedCountry: dataSelectedCountry.map((el) => {
+ if (el.total_evaluated === 0) {
+ return { ...el, ratio: 0 };
+ }
+ return {
+ ...el,
+ ratio: (el.total_successful / el.total_evaluated) * 100,
+ };
+ }),
+ otherCountries: otherCountries.map((el) => {
+ if (el.total_evaluated === 0) {
+ return { ...el, ratio: 0 };
+ }
+ return {
+ ...el,
+ ratio: (el.total_successful / el.total_evaluated) * 100,
+ };
+ }),
+ };
+
+ return res.json(data);
+ });
- // }
- // },
- // otherCountries: {
- // $filter:
- // {
- // input: "$otherCountries",
- // as: "otherCountriesFiltered",
- // cond: { $ne: ["$$otherCountriesFiltered", null] },
- // }
- // },
- // }
- // },
- // ]).toArray();
+router
+ .route(
+ "/european-projects/general-projectsTypes-successRateForAmountsByPillar"
+ )
+ .get(async (req, res) => {
+ if (!req.query.country_code) {
+ res.status(400).send("country_code is required");
+ return;
+ }
+ if (req.query.country_code) {
+ req.query.country_code = req.query.country_code.toUpperCase();
+ }
+ const dataSelectedCountry = await db
+ .collection("fr-esr-all-projects-synthese")
+ .aggregate([
+ { $match: { country_code: req.query.country_code } },
+ {
+ $group: {
+ _id: {
+ stage: "$stage",
+ pilier_name_fr: "$pilier_name_fr",
+ pilier_name_en: "$pilier_name_en",
+ },
+ total_fund_eur: { $sum: "$fund_eur" },
+ },
+ },
+ {
+ $project: {
+ _id: 0,
+ stage: "$_id.stage",
+ total_fund_eur: 1,
+ pilier_name_fr: "$_id.pilier_name_fr",
+ pilier_name_en: "$_id.pilier_name_en",
+ },
+ },
+ {
+ $group: {
+ _id: {
+ id: "$pilier_name_fr",
+ name: "$pilier_name_en",
+ },
+ total_successful: {
+ $sum: {
+ $cond: [
+ { $eq: ["$stage", "successful"] },
+ "$total_fund_eur",
+ 0,
+ ],
+ },
+ },
+ total_evaluated: {
+ $sum: {
+ $cond: [{ $eq: ["$stage", "evaluated"] }, "$total_fund_eur", 0],
+ },
+ },
+ },
+ },
+ {
+ $project: {
+ _id: 0,
+ id: "$_id.id",
+ name: "$_id.name",
+ total_successful: 1,
+ total_evaluated: 1,
+ },
+ },
+ { $sort: { id: 1 } },
+ ])
+ .toArray();
+
+ const otherCountries = await db
+ .collection("fr-esr-all-projects-synthese")
+ .aggregate([
+ { $match: { country_association_code: "MEMBER-ASSOCIATED" } },
+ {
+ $group: {
+ _id: {
+ stage: "$stage",
+ pilier_name_fr: "$pilier_name_fr",
+ pilier_name_en: "$pilier_name_en",
+ },
+ total_fund_eur: { $sum: "$fund_eur" },
+ },
+ },
+ {
+ $project: {
+ _id: 0,
+ stage: "$_id.stage",
+ total_fund_eur: 1,
+ pilier_name_fr: "$_id.pilier_name_fr",
+ pilier_name_en: "$_id.pilier_name_en",
+ },
+ },
+ {
+ $group: {
+ _id: {
+ id: "$pilier_name_fr",
+ name: "$pilier_name_en",
+ },
+ total_successful: {
+ $sum: {
+ $cond: [
+ { $eq: ["$stage", "successful"] },
+ "$total_fund_eur",
+ 0,
+ ],
+ },
+ },
+ total_evaluated: {
+ $sum: {
+ $cond: [{ $eq: ["$stage", "evaluated"] }, "$total_fund_eur", 0],
+ },
+ },
+ },
+ },
+ {
+ $project: {
+ _id: 0,
+ id: "$_id.id",
+ name: "$_id.name",
+ total_successful: 1,
+ total_evaluated: 1,
+ },
+ },
+ { $sort: { id: 1 } },
+ ])
+ .toArray();
const data = {
selectedCountry: dataSelectedCountry.map((el) => {