[Pkg-mozext-commits] [perspectives-extension] 03/03: Perspectives - Add min and max bounds on getQuorumAsInt()

David Prévot taffit at alioth.debian.org
Mon Sep 30 02:15:03 UTC 2013


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch patch-queue/wheezy
in repository perspectives-extension.

commit 29d66686809533884bfb5bb8066285377d0c2c65
Author: Dave Schaefer <dave.schaefer at gmail.com>
Date:   Wed Sep 18 21:30:00 2013 -0600

    Perspectives - Add min and max bounds on getQuorumAsInt()
    
    These were somewhat enforced in the UI, but we need to also
    enforce them here in case the user picks a really low value.
    
    Origin: upstream, https://github.com/danwent/Perspectives/commit/1f85a52364d59199babfb0d55ea48a38ce0e32ae
    Bug: https://github.com/danwent/Perspectives/issues/87
---
 plugin/chrome/content/notaries.js |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/plugin/chrome/content/notaries.js b/plugin/chrome/content/notaries.js
index cb12d61..cc9ba28 100644
--- a/plugin/chrome/content/notaries.js
+++ b/plugin/chrome/content/notaries.js
@@ -394,9 +394,21 @@ var Perspectives = {
 	// return the quorum as an integer
 	// e.g. useful for comparing against the number of results
 	getQuorumAsInt: function() {
+		var MIN_NOTARY_COUNT = 1;
+		//FIXME: we can cache the value inside getNotaryList() if calling is too slow.
+		var notary_count = this.getNotaryList().length;
 		var q_thresh = Perspectives.root_prefs.
 				getIntPref("perspectives.quorum_thresh") / 100;
-		return Math.round(this.all_notaries.length * q_thresh);
+		var q_count = Math.round(notary_count * q_thresh);
+
+		if (q_count < MIN_NOTARY_COUNT) {
+			q_count = MIN_NOTARY_COUNT;
+		}
+		else if (q_count > notary_count) {
+			q_count = notary_count;
+		}
+
+		return q_count;
 	},
 
 	notaryQueriesComplete: function(ti) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/perspectives-extension.git



More information about the Pkg-mozext-commits mailing list