forked from GitHub/dbot
		
	fix the poll views
This commit is contained in:
		
							parent
							
								
									faaee59116
								
							
						
					
					
						commit
						68e13e7bcd
					
				| @ -1,4 +1,5 @@ | ||||
| var _ = require('underscore')._; | ||||
| var _ = require('underscore')._, | ||||
|     async = require('async'); | ||||
| 
 | ||||
| var pages = function(dbot) { | ||||
|     var pages = { | ||||
| @ -7,30 +8,29 @@ var pages = function(dbot) { | ||||
|             var key = req.params.key.toLowerCase(); | ||||
|             this.db.read('poll', key, function(err, poll) { | ||||
|                 if(!err) { | ||||
|                 console.log(poll); | ||||
|                     var totalVotes = _.reduce(poll.votes, function(memo, option) { | ||||
|                         return memo += option; | ||||
|                     }, 0); | ||||
| 
 | ||||
|                     var voterNicks = []; | ||||
|                     /* TODO: Fix stupid fucking async issue bullshit | ||||
|                     var voterNicks = _.map(poll.votees, function(vote, id) { | ||||
|                     async.each(_.keys(poll.votees), function(id, done) { | ||||
|                         dbot.api.users.getUser(id, function(user) { | ||||
|                             return user.primaryNick; | ||||
|                             voterNicks.push(user.primaryNick); | ||||
|                             done(); | ||||
|                         }); | ||||
|                     });*/ | ||||
| 
 | ||||
|                     process.nextTick(function() { | ||||
|                         console.log(voterNicks); | ||||
|                     }, function() { | ||||
|                         res.render('polls', {  | ||||
|                             'name': dbot.config.name,  | ||||
|                             'description': poll.description,  | ||||
|                             'votees': voterNicks, | ||||
|                             'options': poll.votes, | ||||
|                             'totalVotes': totalVotes,  | ||||
|                             locals: {  | ||||
|                                 'totalVotes': totalVotes,  | ||||
|                                 'url_regex': RegExp.prototype.url_regex()  | ||||
|                             } | ||||
|                         }); | ||||
| 
 | ||||
|                     }); | ||||
|                 } else { | ||||
|                     res.render('error', {  | ||||
|  | ||||
| @ -4,7 +4,7 @@ block content | ||||
|     div#backlink  | ||||
|         a(href='/poll/') « Poll list | ||||
|     h2 #{description} | ||||
|     p Voters (#{locals.totalVotes}):  | ||||
|     p Voters (#{votees.length}):  | ||||
|         -each voter in votees | ||||
|              |  #{voter} | ||||
|     ul#votelist | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 reality
						reality