Published
Edited
Oct 9, 2019
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
fastPayoutProportion = 1/5
Insert cell
totalFastPayout = totalPayout * fastPayoutProportion
Insert cell
totalSlowPayout = totalPayout * (1-fastPayoutProportion)
Insert cell
Insert cell
Insert cell
Insert cell
targetPayoutPerCred = (sumPastPayout + totalPayout) / sumTotalCred
Insert cell
Insert cell
Insert cell
Insert cell
slowPayout = aliasMap((a) => Math.floor(userUnderpayment.get(a) / totalUserUnderpayment * totalSlowPayout))
Insert cell
hash="b8f71768b0427e0b189578d96b421ed4120e7a8c"
Insert cell
last_week_hash="96b614ad8067ea62f789a073366677e763a40eba"
Insert cell
weeklyPayout = aliasMap((a) => fastPayout.get(a) + slowPayout.get(a))
Insert cell
aliasMap = (f) => new Map(aliases.map((a) => [a, f(a)]))
Insert cell
d3 = require("d3@5")
Insert cell
Insert cell
distribution_history_file = `https://raw.githubusercontent.com/sourcecred/cred/${hash}/distributionHistory.json`
Insert cell
distributionHistoryLoaded=(await (await fetch(distribution_history_file)).json());
Insert cell
lastWeekDistributionHistory=(await (await fetch(`https://raw.githubusercontent.com/sourcecred/cred/${last_week_hash}/distributionHistory.json`)).json());
Insert cell
distributionMatches = JSON.stringify(distributionHistoryLoaded) === JSON.stringify(distributionHistory)
Insert cell
aliases = scores.users.map((u) => addressToAlias(u.address))
Insert cell
top_aliases = aliases.filter((a) => totalProportion.get(a) > 0.01 || latestProportion.get(a) > 0.01)
Insert cell
latestCred = aliasMap((a) => intervalCred.get(a)[last_week_idx])
Insert cell
sumLatestCred = d3.sum(Array.from(latestCred.values()))
Insert cell
latestProportion = aliasMap((a) => latestCred.get(a) / sumLatestCred)
Insert cell
totalProportion = aliasMap((a) => totalCred.get(a) / sumTotalCred)
Insert cell
totalCred = aliasMap((a) => d3.sum(intervalCred.get(a).slice(0,last_week_idx+1)))
Insert cell
sumTotalCred = d3.sum(Array.from(totalCred.values()))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
dollarFormat = (x) => d3.format("$.2f")(x/100)
Insert cell
credFormat = d3.format(".0f")

Insert cell
percentFormat = d3.format(".1%")
Insert cell
Insert cell
manaFormat = (x) => d3.format(",.0f")(x) + "`¤`"

Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more