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

Fix/ndc parties inconsistency #1674

Merged
merged 2 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -482,19 +482,20 @@ export const getVulnerabilityData = createSelector(
);

const getCountriesAndParties = submissions => {
const countriesSubmissions = submissions.filter(s => s !== europeSlug);
const partiesNumber = submissions.length;
let countriesNumber = submissions.length;
let countriesNumber = countriesSubmissions.length;

if (!submissions.includes(europeGroupExplorerPagesSlug)) {
return { partiesNumber, countriesNumber };
if (submissions.includes(europeGroupExplorerPagesSlug)) {
const europeanCountriesWithSubmission = intersection(
europeanCountries,
countriesSubmissions
);

countriesNumber +=
europeanCountries.length - (europeanCountriesWithSubmission.length - 1);
}
const europeanCountriesWithSubmission = intersection(
europeanCountries,
submissions
);

countriesNumber +=
europeanCountries.length - (europeanCountriesWithSubmission.length - 1) - 1; // Don't count the EUU
return { partiesNumber, countriesNumber };
};

Expand Down
10 changes: 8 additions & 2 deletions app/javascript/app/components/ndcs/shared/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ export const selectedCountriesFunction = (locations, regions, countries) => {
if (!locations || !locations.length || !regions || !regions.length) {
return countries;
}
const PARTIES_MISSING_IN_WORLD_SECTION = [...NO_DOCUMENT_SUBMITTED_COUNTRIES];

const EUURegion = regions.find(r => r.iso_code3 === 'EUU');
// EUU as a country is not included in the WORLD section
const PARTIES_MISSING_IN_WORLD_SECTION = [
...NO_DOCUMENT_SUBMITTED_COUNTRIES,
{ iso: europeSlug, label: EUURegion?.label }
];
const selectedRegionsCountries = locations.reduce((acc, location) => {
let members = acc;
if (location.iso === 'TOP') {
Expand Down Expand Up @@ -82,9 +88,9 @@ export const selectedCountriesFunction = (locations, regions, countries) => {
return false;
});
}

return members;
}, []);

const selectedRegionsCountriesISOS = selectedRegionsCountries.map(
c => c.iso_code3
);
Expand Down
Loading