Skip to content

Commit

Permalink
[Platform]: prioritisation to disease assoc export on ppp (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
carcruz authored Sep 25, 2023
1 parent 2a8c86d commit 425e7d5
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { faCloudArrowDown } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import useAotfContext from './hooks/useAotfContext';
import dataSources from './static_datasets/dataSourcesAssoc';
import prioritizationCols from './static_datasets/prioritizationCols';
import { isPartnerPreview } from './utils';

const PopoverContent = styled('div')({
padding: '20px 25px',
Expand Down Expand Up @@ -51,24 +53,43 @@ const getRowsQuerySelector = entityToGet =>

const getExportedColumns = entityToGet => {
const nameColumn = entityToGet === 'target' ? targetName : diseaseName;
let exportedColumns = [];
const sources = dataSources.map(({ id }) => ({
id,
exportValue: data => {
const datatypeScore = data.datasourceScores.find(
datasourceScore => datasourceScore.componentId === id
);
return datatypeScore ? datatypeScore.score : 'No data';
return datatypeScore ? parseFloat(datatypeScore.score) : 'No data';
},
}));

exportedColumns = [...sources];

if (entityToGet === 'target' && isPartnerPreview) {
const prioritisationExportCols = prioritizationCols.map(({ id }) => ({
id,
exportValue: data => {
const prioritisationScore = data.target.prioritisation.items.find(
prioritisationItem => prioritisationItem.key === id
);
return prioritisationScore
? parseFloat(prioritisationScore.value)
: 'No data';
},
}));

exportedColumns = [...sources, ...prioritisationExportCols];
}

return [
nameColumn,
{
id: 'score',
label: 'Score',
exportValue: data => data.score,
},
...sources,
...exportedColumns,
];
};

Expand Down

0 comments on commit 425e7d5

Please sign in to comment.