Published
Edited
Oct 2, 2019
1 fork
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
Insert cell
slowPayout = aliasMap(
(a) => Math.floor(payoutAmountCents * (1 - fastPayoutProportion) * totalCred.get(a) / sumTotalCred)
)
Insert cell
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
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
sha256(JSON.stringify("foo"))
Insert cell
JSON.stringify(3)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
d = d3.format("$.1f")
Insert cell
c = d3.format(".0f")

Insert cell
p = d3.format(".1%")
Insert cell
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