Published
Edited
Sep 25, 2019
1 fork
1 star
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) => payoutAmount * (1 - fastPayoutProportion) * totalCred.get(a) / sumTotalCred
)
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
hash="82a023825ed96903346c3cc82aa2a22bfe125f53"
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
intervalCred = new Map(scores.users.map((u) => {
const alias = addressToAlias(u.address);
return [alias, u.intervalCred];
}
))
Insert cell
Insert cell
addressToAlias = (address) => {
switch (address[1]) {
case "identity": return `sc/@${address[2]}`
case "discourse": return `d/@${address[4]}`
case "github": return `gh/@${address[4]}`
default: throw new Error("bad address")
}
}
Insert cell
d = d3.format("$.1f")
Insert cell
c = d3.format(".0f")

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