Last active
February 14, 2016 02:42
-
-
Save BrynM/9f38d174f284088423cd to your computer and use it in GitHub Desktop.
GifTournament seeding round report generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Just run this whole thing on the browser console (copy/paste) | |
// while on the seeding comments page. | |
var stor = {}; | |
var ranks = []; | |
var $tags = $('.commentarea > .nestedlisting > .comment:not(.deleted) > .entry > .tagline'); | |
var rankRpt = 'RANKINGS:'; | |
var matchRpt = 'MATCHES:'; | |
var overRpt = 'OVERFLOW USERS:'; | |
var bye = '*bye*'; | |
var competitors; | |
var matches = 0; | |
var overflow; | |
var overCount; | |
var competitors = 92; | |
// get data | |
for(var i = 0; i < $tags.length; i++) { | |
var $ele = $($tags[i]); | |
var user = $ele.find('.author').text(); | |
stor[user] = { | |
el: $ele, | |
score: $ele.find('.score.likes').text().match(/[0-9]+/).pop() | |
}; | |
ranks.push(user); | |
} | |
// pop a buy score onto the stor | |
stor[bye] = {score:0}; | |
// generate rank report | |
for(var i = 0; i < ranks.length; i++) { | |
rankRpt += '\n '+(i+1)+' '+ranks[i]+' '+stor[ranks[i]].score+' points'; | |
} | |
// generate matches report | |
competitors = ranks.slice(0, competitors); | |
// currently the overflow is not reported on | |
overflow = ranks.length > competitors ? ranks.slice(competitors, ranks.length+1) : []; | |
// push until N competitors | |
while(competitors.length < competitors) { | |
competitors.push(bye) | |
} | |
// do the matching from outside to middle | |
while(competitors.length > 0) { | |
var hi = competitors.shift(); | |
var lo = competitors.pop(); | |
matches++; | |
matchRpt += '\n '+matches+': /u/'+hi+' ('+stor[hi].score+'pts) ~~VS~~ /u/'+lo+' ('+stor[lo].score+'pts)'; | |
} | |
// report on the overflow users while ranking them | |
overCount = 0; | |
while(overflow.length > 0) { | |
var u = overflow.shift(); | |
overCount++; | |
overRpt+= '\n '+overCount+' /u/'+u+' ('+stor[u].score+'pts)'; | |
} | |
// spit the reports | |
console.log('\n%c#'+rankRpt, 'background: transparent; color: green; font-size: 10px; font-style:bold; font-family: monospace; display: block; width: 90%'); | |
console.log('\n%c#'+matchRpt, 'background: transparent; color: blue; font-size: 10px; font-style:bold; font-family: monospace; display: block; width: 90%'); | |
console.log('\n%c#'+overRpt, 'background: transparent; color: red; font-size: 10px; font-style:bold; font-family: monospace; display: block; width: 90%'); |
Added in reporting and ranking the overflow users as well.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should end up with something like this.