Last active
August 29, 2015 14:04
-
-
Save tfogo/3c972a85e068fe0afae6 to your computer and use it in GitHub Desktop.
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
var mongoose = require('mongoose'); | |
// config | |
var config = require('./config'); | |
// mongodb URI | |
var uristring = config.db; | |
// connect to db | |
mongoose.connect(uristring); | |
var db = mongoose.connection; | |
db.on('error', console.error.bind(console, 'connection error:')); | |
db.once('open', function(){ | |
console.log("Mongoose started!"); | |
}); | |
// mongoose models | |
require('./models'); | |
var Video = mongoose.model('Video'); | |
var Tag = mongoose.model('Tag'); | |
var User = mongoose.model('User'); | |
rankings = {}; | |
for (var i = 0; i < 30; i++) { | |
rankings['p'+i] = 0; | |
} | |
tags.forEach(function(tag){ | |
rankings[tag.username]++; | |
}).exec(function(){ | |
var sortable = []; | |
for (var user in rankings) { | |
sortable.push([user, rankings[user]]); | |
} | |
sortable.sort(function(a, b) {return a[1] - b[1]}); | |
console.log(sortable); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment