feat: Added GiveWell points of comparison

Taken from: https://docs.google.com/spreadsheets/d/11HsJLpq0Suf3SK_PmzzWpK1tr_BTd364j0l3xVvSCQw/edit#gid=1362437801
This commit is contained in:
NunoSempere 2021-09-22 21:45:18 +02:00
parent 134e526f74
commit 010a9b3b27
3 changed files with 136 additions and 104 deletions

View File

@ -16,7 +16,7 @@ const railStyle = {
position: 'absolute', position: 'absolute',
width: '100%', width: '100%',
height: 15, height: 15,
marginTop: 30, marginTop: 25,
borderRadius: 5, borderRadius: 5,
backgroundColor: 'lightgrey', backgroundColor: 'lightgrey',
} }
@ -77,12 +77,13 @@ function Track({ source, target, getTrackProps }) {
/* Body */ /* Body */
// Two functions, essentially identical. // Two functions, essentially identical.
export function SliderElement({ onChange, value, displayFunction }) { export function SliderElement({ onChange, value, displayFunction }) {
let toLogDomain = (arr) => [Math.log(arr[0])/Math.log(10), Math.log(arr[1])/Math.log(10)]
return ( return (
<Slider <Slider
rootStyle={sliderStyle /* inline styles for the outer div. Can also use className prop. */} rootStyle={sliderStyle /* inline styles for the outer div. Can also use className prop. */}
domain={[-3,3]} domain={toLogDomain([1/250,250])}
values={[value]} values={[value]}
step={0.0001}
onChange={onChange} onChange={onChange}
reversed={true} reversed={true}
> >

View File

@ -31,14 +31,16 @@ let checkIfListIsOrdered = (arr, binaryComparisons) => {
return isOrdered return isOrdered
} }
let simplifySliderValue = value => 10**value >= 3 ? Math.round(10**value) : Math.round(10*10**value)/10 let transformSliderValueToActualValue = value => 10 ** value //>= 2 ? Math.round(10 ** value) : Math.round(10 * 10 ** value) / 10
let truncateValueForDisplay = value => value > 10 ? Math.round(value) : Math.round(value*10)/10
let transformSliderValueToPracticalValue = value => truncateValueForDisplay(transformSliderValueToActualValue(value))
let displayFunctionSlider = (value) => { let displayFunctionSlider = (value) => {
let result let result
if (value >= 0) { if (value >= 0) {
result = simplifySliderValue(value) result = transformSliderValueToPracticalValue(value)
} else { } else {
let inverseresult = simplifySliderValue(-value) let inverseresult = transformSliderValueToPracticalValue(-value)
result = `1/${inverseresult}` result = `1/${inverseresult}`
} }
result = `The first option is ${result}x as valuable as the second one` result = `The first option is ${result}x as valuable as the second one`
@ -54,12 +56,12 @@ export async function getStaticProps() {
//getServerSideProps //getServerSideProps
// const { metaforecasts } = await getForecasts(); // const { metaforecasts } = await getForecasts();
const directory = path.join(process.cwd(), "pages") const directory = path.join(process.cwd(), "pages")
let listOfPosts = JSON.parse(fs.readFileSync(path.join(directory, 'listOfPosts.json'), 'utf8')); let listOfMoralGoods = JSON.parse(fs.readFileSync(path.join(directory, 'listOfMoralGoods.json'), 'utf8'));
//console.log(directory) //console.log(directory)
//console.log("metaforecasts", metaforecasts) //console.log("metaforecasts", metaforecasts)
return { return {
props: { props: {
listOfElementsDefault: listOfPosts, listOfElementsDefault: listOfMoralGoods,
}, },
}; };
} }
@ -212,7 +214,7 @@ export default function Home({listOfElementsDefault}) {
console.log(posList) console.log(posList)
nextStepSimple(posList, binaryComparisons, element1, element2) nextStepSimple(posList, binaryComparisons, element1, element2)
let newQuantitativeComparison = [element1, element2, simplifySliderValue(sliderValue)] let newQuantitativeComparison = [element1, element2, transformSliderValueToPracticalValue(sliderValue)]
let newQuantitativeComparisons = [...quantitativeComparisons, newQuantitativeComparison] let newQuantitativeComparisons = [...quantitativeComparisons, newQuantitativeComparison]
setQuantitativeComparisons(newQuantitativeComparisons) setQuantitativeComparisons(newQuantitativeComparisons)

View File

@ -0,0 +1,29 @@
[
{
"name": "Doubling consumption for one person for one year",
"note": "(at fairly low levels of wealth)",
"isReferenceValue": true
},
{
"name": "Averting the death of an individual under 5 from malaria"
},
{
"name": "Averting the death of an individual 5 or older from malaria"
},
{
"name": "Averting the death of a 6- to 59-month-old child",
"note": "(through Vitamin A Supplementation)"
},
{
"name": "Averting the death of an individual under 5 from vaccine-preventable diseases"
},
{
"name": "Averting the death of an individual 5-14 years old from vaccine-preventable diseases"
},
{
"name": "Averting the death of an individual 15-49 years old from vaccine-preventable diseases"
},
{
"name": "Averting the death of an individual 50-74 years old from vaccine-preventable diseases"
}
]