From 286a093540a200bcdae34d908e59d5290ea28a4a Mon Sep 17 00:00:00 2001 From: deuce <> Date: Tue, 26 Jun 2012 23:51:16 +0000 Subject: [PATCH] Make a separate issue.havevoted() method. --- exec/load/consensus_vote.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/exec/load/consensus_vote.js b/exec/load/consensus_vote.js index 0b226e14e2..41c225efa6 100644 --- a/exec/load/consensus_vote.js +++ b/exec/load/consensus_vote.js @@ -72,6 +72,19 @@ function ConcensusObject(host, port, scope) newissue.answers=this.answers; this.db.write(this.scope, 'issues.'+this.index, newissue, LOCK_WRITE); } + issue.havevoted=function() + { + var i,j; + + for(i in this.answers) { + for(j in this.answers[i].votes) { + if(this.answers[i].votes[k]==user.alias) + return true; + } + } + } + return false; + } } this.get_all_issues=function() @@ -141,19 +154,11 @@ function ConcensusObject(host, port, scope) this.get_pending_issues=function() { var all=this.get_open_issues(); - var i,j,k; - var matched; + var i; var ret=[]; for(i in all) { - matched=0; - for(j in all[i].answers) { - for(k in all[i].answers[j].votes) { - if(all[i].answers[j].votes[k]==user.alias) - matched++; - } - } - if(!matched) + if(!all[i].havevoted()) ret.push(all[i]); } return ret; -- GitLab