better calculations
This commit is contained in:
parent
4beeb3cbf3
commit
c79764b523
1 changed files with 15 additions and 10 deletions
25
js/app.js
25
js/app.js
|
@ -3,19 +3,24 @@ let entries = [];
|
|||
let users = {};
|
||||
|
||||
let fetchData;
|
||||
|
||||
let sum = 0;
|
||||
|
||||
async function genTree(treeId) {
|
||||
let entry = treeId;
|
||||
|
||||
entries.push(treeId)
|
||||
let entry = fetchData[treeId];
|
||||
|
||||
while (entry) {
|
||||
entry = entry.parent_id;
|
||||
entries.push(entry);
|
||||
while (true) {
|
||||
let entryDat = fetchData[entry];
|
||||
if (!entryDat) continue;
|
||||
if (!entryDat) break;
|
||||
|
||||
entries.push(entry);
|
||||
|
||||
let us = users[entryDat.username];
|
||||
users[entryDat.username] = (us ? us : 0) + 1 / entries.length;
|
||||
entry = entryDat;
|
||||
|
||||
let s = 1 / (entries.length+10);
|
||||
sum += s;
|
||||
users[entryDat.username] = (us ? us : 0) + s;
|
||||
entry = entryDat.parent_id;
|
||||
}
|
||||
|
||||
return entry;
|
||||
|
@ -39,7 +44,7 @@ async function main() {
|
|||
doThings = true;
|
||||
document.querySelector('.contributors').innerHTML = Object.keys(users)
|
||||
.sort((x, y) => users[y] - users[x])
|
||||
.map(x => `<a href='https://scratch.mit.edu/users/${x}'>${x}</a> <sub>${Math.trunc(users[x] / Math.log(entries.length) * 100000) / 1000}%</sub>`)
|
||||
.map(x => `<a href='https://scratch.mit.edu/users/${x}'>${x}</a> <sub>${Math.trunc(users[x] / sum * 100000) / 1000}%</sub>`)
|
||||
.join(', '); // Doesn't need to be sanitized (hopefully)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue