Published
Edited
Oct 18, 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
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="2f3772160ad90d46754d6d5e1f56662e20b01b69"
Insert cell
last_week_hash="0a323f45f940807645ce9769b912af826833075f"
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
grainFormat = (x) => d3.format(",.0f")(x) + "`¤`"

Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more