[Pkg-mozext-commits] [perspectives-extension] 24/30: Perspectives - Add min and max bounds on getQuorumAsInt() GH 87.
David Prévot
taffit at alioth.debian.org
Thu Sep 26 22:31:41 UTC 2013
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch debian
in repository perspectives-extension.
commit 1f85a52364d59199babfb0d55ea48a38ce0e32ae
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()
GH 87.
These were somewhat enforced in the UI, but we need to also
enforce them here in case the user picks a really low value.
---
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 730e9bd..04f136c 100644
--- a/plugin/chrome/content/notaries.js
+++ b/plugin/chrome/content/notaries.js
@@ -412,9 +412,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