Revision 58946
Added by Stefania Martziou almost 4 years ago
data-handler.service.ts | ||
---|---|---|
595 | 595 |
return tableData; |
596 | 596 |
} |
597 | 597 |
|
598 |
public convertRawDataToIndicatorsTableData(rawData: RawData) { |
|
599 |
|
|
600 |
const mapTableData: Map<string, CountryTableData> = new Map(); |
|
601 |
|
|
602 |
for (const series of rawData.datasets) { |
|
603 |
|
|
604 |
if (series.series.query.name.includes('new.oso.results.pid_percentage')) { |
|
605 |
for (const rowResult of series.series.result) { |
|
606 |
|
|
607 |
const pidIndicator = new Indicator(); |
|
608 |
|
|
609 |
// remove unwanted countries |
|
610 |
if (this.isCountryToBeRemoved(rowResult.row[3])) { |
|
611 |
continue; |
|
612 |
} |
|
613 |
|
|
614 |
if (mapTableData.has(rowResult.row[3])) { |
|
615 |
const countryTableData = mapTableData.get(rowResult.row[3]); |
|
616 |
if (rowResult.row[0] !== 'NaN') { |
|
617 |
pidIndicator.total = Number(rowResult.row[2]); |
|
618 |
pidIndicator.oa = Number(rowResult.row[1]); |
|
619 |
pidIndicator.percentage = Number(rowResult.row[0]); |
|
620 |
countryTableData.pid = pidIndicator; |
|
621 |
} |
|
622 |
} else { |
|
623 |
const countryTableData: CountryTableData = new CountryTableData(); |
|
624 |
if (rowResult.row[0] !== 'NaN') { |
|
625 |
pidIndicator.total = Number(rowResult.row[2]); |
|
626 |
pidIndicator.oa = Number(rowResult.row[1]); |
|
627 |
pidIndicator.percentage = Number(rowResult.row[0]); |
|
628 |
countryTableData.pid = pidIndicator; |
|
629 |
} |
|
630 |
countryTableData.name = rowResult.row[4]; |
|
631 |
countryTableData.code = rowResult.row[3]; |
|
632 |
mapTableData.set(rowResult.row[3], countryTableData); |
|
633 |
} |
|
634 |
} |
|
635 |
|
|
636 |
} else if (series.series.query.name.includes('new.oso.results.licence_percentage')) { |
|
637 |
|
|
638 |
for (const rowResult of series.series.result) { |
|
639 |
|
|
640 |
const licenceIndicator = new Indicator(); |
|
641 |
|
|
642 |
// remove unwanted countries |
|
643 |
if (this.isCountryToBeRemoved(rowResult.row[3])) { |
|
644 |
continue; |
|
645 |
} |
|
646 |
|
|
647 |
if (mapTableData.has(rowResult.row[3])) { |
|
648 |
const countryTableData = mapTableData.get(rowResult.row[3]); |
|
649 |
if (rowResult.row[0] !== 'NaN') { |
|
650 |
licenceIndicator.total = Number(rowResult.row[2]); |
|
651 |
licenceIndicator.oa = Number(rowResult.row[1]); |
|
652 |
licenceIndicator.percentage = Number(rowResult.row[0]); |
|
653 |
countryTableData.licence = licenceIndicator; |
|
654 |
} |
|
655 |
} else { |
|
656 |
const countryTableData: CountryTableData = new CountryTableData(); |
|
657 |
if (rowResult.row[0] !== 'NaN') { |
|
658 |
licenceIndicator.total = Number(rowResult.row[2]); |
|
659 |
licenceIndicator.oa = Number(rowResult.row[1]); |
|
660 |
licenceIndicator.percentage = Number(rowResult.row[0]); |
|
661 |
countryTableData.licence = licenceIndicator; |
|
662 |
} |
|
663 |
countryTableData.name = rowResult.row[4]; |
|
664 |
countryTableData.code = rowResult.row[3]; |
|
665 |
mapTableData.set(rowResult.row[3], countryTableData); |
|
666 |
} |
|
667 |
} |
|
668 |
} else if (series.series.query.name.includes('new.oso.results.green_percentage')) { |
|
669 |
|
|
670 |
for (const rowResult of series.series.result) { |
|
671 |
|
|
672 |
const greenIndicator = new Indicator(); |
|
673 |
|
|
674 |
// remove unwanted countries |
|
675 |
if (this.isCountryToBeRemoved(rowResult.row[3])) { |
|
676 |
continue; |
|
677 |
} |
|
678 |
|
|
679 |
if (mapTableData.has(rowResult.row[3])) { |
|
680 |
const countryTableData = mapTableData.get(rowResult.row[3]); |
|
681 |
if (rowResult.row[0] !== 'NaN') { |
|
682 |
greenIndicator.total = Number(rowResult.row[2]); |
|
683 |
greenIndicator.oa = Number(rowResult.row[1]); |
|
684 |
greenIndicator.percentage = Number(rowResult.row[0]); |
|
685 |
countryTableData.green = greenIndicator; |
|
686 |
} |
|
687 |
} else { |
|
688 |
const countryTableData: CountryTableData = new CountryTableData(); |
|
689 |
if (rowResult.row[0] !== 'NaN') { |
|
690 |
greenIndicator.total = Number(rowResult.row[2]); |
|
691 |
greenIndicator.oa = Number(rowResult.row[1]); |
|
692 |
greenIndicator.percentage = Number(rowResult.row[0]); |
|
693 |
countryTableData.green = greenIndicator; |
|
694 |
} |
|
695 |
countryTableData.name = rowResult.row[4]; |
|
696 |
countryTableData.code = rowResult.row[3]; |
|
697 |
mapTableData.set(rowResult.row[3], countryTableData); |
|
698 |
} |
|
699 |
} |
|
700 |
} else if (series.series.query.name.includes('new.oso.results.gold_percentage')) { |
|
701 |
|
|
702 |
for (const rowResult of series.series.result) { |
|
703 |
|
|
704 |
const goldIndicator = new Indicator(); |
|
705 |
|
|
706 |
// remove unwanted countries |
|
707 |
if (this.isCountryToBeRemoved(rowResult.row[3])) { |
|
708 |
continue; |
|
709 |
} |
|
710 |
|
|
711 |
if (mapTableData.has(rowResult.row[3])) { |
|
712 |
const countryTableData = mapTableData.get(rowResult.row[3]); |
|
713 |
if (rowResult.row[0] !== 'NaN') { |
|
714 |
goldIndicator.total = Number(rowResult.row[2]); |
|
715 |
goldIndicator.oa = Number(rowResult.row[1]); |
|
716 |
goldIndicator.percentage = Number(rowResult.row[0]); |
|
717 |
countryTableData.gold = goldIndicator; |
|
718 |
} |
|
719 |
} else { |
|
720 |
const countryTableData: CountryTableData = new CountryTableData(); |
|
721 |
if (rowResult.row[0] !== 'NaN') { |
|
722 |
goldIndicator.total = Number(rowResult.row[2]); |
|
723 |
goldIndicator.oa = Number(rowResult.row[1]); |
|
724 |
goldIndicator.percentage = Number(rowResult.row[0]); |
|
725 |
countryTableData.gold = goldIndicator; |
|
726 |
} |
|
727 |
countryTableData.name = rowResult.row[4]; |
|
728 |
countryTableData.code = rowResult.row[3]; |
|
729 |
mapTableData.set(rowResult.row[3], countryTableData); |
|
730 |
} |
|
731 |
} |
|
732 |
} |
|
733 |
} |
|
734 |
|
|
735 |
const tableData: CountryTableData[] = []; |
|
736 |
|
|
737 |
mapTableData.forEach((value: CountryTableData, key: string) => { |
|
738 |
// console.log(key, value); |
|
739 |
tableData.push(value); |
|
740 |
}); |
|
741 |
|
|
742 |
return tableData; |
|
743 |
} |
|
744 |
|
|
598 | 745 |
public convertRawDataToLeadingOpenScienceData(rawData: RawData) { |
599 | 746 |
|
600 | 747 |
const leadingOpenScienceData: CountryOverviewData[] = []; |
Also available in: Unified diff
Created the indicator tables for the open science tab of the europe page