diff --git a/classes/cache.class.php b/classes/cache.class.php
index 2a2d39e8..b671e19d 100644
--- a/classes/cache.class.php
+++ b/classes/cache.class.php
@@ -39,6 +39,7 @@ class CACHE extends Memcache {
public $MemcacheDBKey = '';
protected $InTransaction = false;
public $Time = 0;
+ private $Servers = array();
private $PersistentKeys = array(
'ajax_requests_*',
'query_lock_*',
@@ -57,6 +58,7 @@ class CACHE extends Memcache {
public $InternalCache = true;
function __construct($Servers) {
+ $this->Servers = $Servers;
foreach ($Servers as $Server) {
$this->addServer($Server['host'], $Server['port'], true, $Server['buckets']);
}
@@ -357,4 +359,17 @@ public function get_query_lock($LockName) {
public function clear_query_lock($LockName) {
$this->delete_value('query_lock_'.$LockName);
}
+
+ /**
+ * Get cache server status
+ *
+ * @return array (host => bool status, ...)
+ */
+ public function server_status() {
+ $Status = array();
+ foreach ($this->Servers as $Server) {
+ $Status["$Server[host]:$Server[port]"] = $this->getServerStatus($Server['host'], $Server['port']);
+ }
+ return $Status;
+ }
}
diff --git a/classes/debug.class.php b/classes/debug.class.php
index d50f4138..d9d64fee 100644
--- a/classes/debug.class.php
+++ b/classes/debug.class.php
@@ -52,6 +52,13 @@ public function profile($Automatic = '') {
$Reason[] = $DBWarningCount . ' DB warning(s)';
}*/
+ $CacheStatus = G::$Cache->server_status();
+ if (in_array(0, $CacheStatus) && !G::$Cache->get_value('cache_fail_reported')) {
+ // Limit to max one report every 15 minutes to avoid massive debug spam
+ G::$Cache->cache_value('cache_fail_reported', true, 900);
+ $Reason[] = "Cache server error";
+ }
+
if (isset($_REQUEST['profile'])) {
$Reason[] = 'Requested by ' . G::$LoggedUser['Username'];
}
@@ -61,6 +68,7 @@ public function profile($Automatic = '') {
$this->Perf['CPU time'] = number_format($this->get_cpu_time() / 1000000, 3).' s';
if (isset($Reason[0])) {
+ $this->log_var($CacheStatus, 'Cache server status');
$this->analysis(implode(', ', $Reason));
return true;
}
@@ -308,7 +316,7 @@ public function perf_table($Perf = false) {
?>
- View Performance stats: |
+ View Performance stats: |
@@ -333,7 +341,7 @@ public function include_table($Includes = false) {
?>
- View =number_format(count($Includes))?> Includes: |
+ View =number_format(count($Includes))?> Includes: |
@@ -357,7 +365,7 @@ public function class_table($Classes = false) {
?>
@@ -374,7 +382,7 @@ public function extension_table() {
?>
@@ -397,7 +405,7 @@ public function flag_table($Flags = false) {
?>
@@ -435,7 +443,7 @@ public function constant_table($Constants = false) {
?>
@@ -462,7 +470,7 @@ public function cache_table($CacheKeys = false) {
?>
@@ -491,7 +499,7 @@ public function error_table($Errors = false) {
?>
- View =number_format(count($Errors))?> Errors: |
+ View =number_format(count($Errors))?> Errors: |
@@ -530,14 +538,16 @@ public function query_table($Queries=false) {
?>
foreach ($Queries as $Query) {
list($SQL, $Time, $Warnings) = $Query;
- $Warnings = implode('
', $Warnings);
+ if ($Warnings !== null) {
+ $Warnings = implode('
', $Warnings);
+ }
?>
=str_replace("\t", ' ', nl2br(display_str($SQL)))?> |
@@ -564,7 +574,7 @@ public function sphinx_table($Queries = false) {
?>
@@ -596,7 +606,7 @@ public function vars_table($Vars = false) {
?>
diff --git a/classes/votes.class.php b/classes/votes.class.php
index 492cd945..1dfc8f84 100644
--- a/classes/votes.class.php
+++ b/classes/votes.class.php
@@ -1,5 +1,11 @@
class Votes {
+ /**
+ * Confidence level for binomial scoring
+ */
+ //const Z_VAL = 1.645211440143815; // p-value .95
+ const Z_VAL = 1.281728756502709; // p-value .90
+
/**
* Generate voting links for torrent pages, etc.
* @param $GroupID
@@ -158,17 +164,12 @@ private function inverse_ncdf($p) {
* @return float Ranking score
*/
public static function binomial_score($Ups, $Total) {
- // Confidence level for binomial scoring (p-value .95)
- //define(Z_VAL, 1.645211440143815);
- // Confidence level for binomial scoring (p-value .90)
- define(Z_VAL, 1.281728756502709);
-
if (($Total <= 0) || ($Ups < 0)) {
return 0;
}
$phat = $Ups / $Total;
- $Numerator = ($phat + Z_VAL * Z_VAL / (2 * $Total) - Z_VAL * sqrt(($phat * (1 - $phat) + Z_VAL * Z_VAL / (4 * $Total)) / $Total));
- $Denominator = (1 + Z_VAL * Z_VAL / $Total);
+ $Numerator = ($phat + self::Z_VAL * self::Z_VAL / (2 * $Total) - self::Z_VAL * sqrt(($phat * (1 - $phat) + self::Z_VAL * self::Z_VAL / (4 * $Total)) / $Total));
+ $Denominator = (1 + self::Z_VAL * self::Z_VAL / $Total);
return ($Numerator / $Denominator);
}
diff --git a/gazelle.sql b/gazelle.sql
index 5abf7344..459e0626 100644
--- a/gazelle.sql
+++ b/gazelle.sql
@@ -1799,9 +1799,9 @@ CREATE TABLE `users_votes` (
`Time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`UserID`,`GroupID`),
KEY `GroupID` (`GroupID`),
- KEY `UserID` (`UserID`),
KEY `Type` (`Type`),
KEY `Time` (`Time`),
+ KEY `Vote` (`Type`,`GroupID`,`UserID`),
CONSTRAINT `users_votes_ibfk_1` FOREIGN KEY (`GroupID`) REFERENCES `torrents_group` (`ID`) ON DELETE CASCADE,
CONSTRAINT `users_votes_ibfk_2` FOREIGN KEY (`UserID`) REFERENCES `users_main` (`ID`) ON DELETE CASCADE
) ENGINE=InnoDB CHARSET utf8;
diff --git a/sections/ajax/takevote.php b/sections/ajax/takevote.php
index a0b72933..5ac3949f 100644
--- a/sections/ajax/takevote.php
+++ b/sections/ajax/takevote.php
@@ -84,7 +84,7 @@
}
}
}
- $Cache->cache_value("vote_pairs_$GroupID", $VotePairs);
+ $Cache->cache_value("vote_pairs_$GroupID", $VotePairs, 21600);
}
// Now do the paired votes keys for all of this guy's other votes
@@ -112,11 +112,10 @@
'Total' => 1,
'Ups' => ($Type == 'Up') ? 1 : 0);
}
- $Cache->cache_value("vote_pairs_$VGID", $VotePairs);
+ $Cache->cache_value("vote_pairs_$VGID", $VotePairs, 21600);
}
}
-
echo 'success';
} elseif ($_REQUEST['do'] == 'unvote') {
if (!isset($UserVotes[$GroupID])) {
@@ -152,13 +151,13 @@
// First update this album's paired votes. If this keys is magically not set,
// our life just got a bit easier. We're only tracking paired votes on upvotes.
if ($Type == 'Up') {
- $VotePairs = $Cache->get_value('vote_pairs_'.$GroupID, true);
+ $VotePairs = $Cache->get_value("vote_pairs_$GroupID", true);
if ($VotePairs !== false) {
foreach ($UserVotes as $Vote) {
if (isset($VotePairs[$Vote['GroupID']])) {
if ($VotePairs[$Vote['GroupID']]['Total'] == 0) {
// Something is screwy
- $Cache->delete_value('vote_pairs_'.$GroupID);
+ $Cache->delete_value("vote_pairs_$GroupID");
continue;
}
$VotePairs[$Vote['GroupID']]['Total'] -= 1;
@@ -167,12 +166,12 @@
}
} else {
// Something is screwy, kill the key and move on
- $Cache->delete_value('vote_pairs_'.$GroupID);
+ $Cache->delete_value("vote_pairs_$GroupID");
break;
}
}
}
- $Cache->cache_value('vote_pairs_'.$GroupID, $VotePairs);
+ $Cache->cache_value("vote_pairs_$GroupID", $VotePairs, 21600);
}
// Now do the paired votes keys for all of this guy's other votes
@@ -185,22 +184,22 @@
continue;
}
// Again, if the cache key is not set, move along
- $VotePairs = $Cache->get_value('vote_pairs_'.$VGID, true);
+ $VotePairs = $Cache->get_value("vote_pairs_$VGID", true);
if ($VotePairs !== false) {
if (isset($VotePairs[$GroupID])) {
if ($VotePairs[$GroupID]['Total'] == 0) {
// Something is screwy
- $Cache->delete_value('vote_pairs_'.$VGID);
+ $Cache->delete_value("vote_pairs_$VGID");
continue;
}
$VotePairs[$GroupID]['Total'] -= 1;
if ($Type == 'Up') {
$VotePairs[$GroupID]['Ups'] -= 1;
}
- $Cache->cache_value('vote_pairs_'.$VGID, $VotePairs);
+ $Cache->cache_value("vote_pairs_$VGID", $VotePairs, 21600);
} else {
// Something is screwy, kill the key and move on
- $Cache->delete_value('vote_pairs_'.$VGID);
+ $Cache->delete_value("vote_pairs_$VGID");
}
}
}
diff --git a/sections/top10/votes.php b/sections/top10/votes.php
index 9a260576..8f6afb16 100644
--- a/sections/top10/votes.php
+++ b/sections/top10/votes.php
@@ -237,10 +237,14 @@
=number_format($DownVotes)?> ∨
- =number_format($TotalVotes)?> Total
+ =number_format($TotalVotes)?> Total
- Score: =number_format($Score * 100, 1)?>
+
+ Score: =number_format($Score * 100, 1)?>
+ |
+ =number_format($UpVotes / $TotalVotes * 100, 1)?>% positive
+
diff --git a/sections/torrents/vote.php b/sections/torrents/vote.php
index 77e8d7cf..1fe9898d 100644
--- a/sections/torrents/vote.php
+++ b/sections/torrents/vote.php
@@ -18,7 +18,7 @@
=number_format($TotalVotes)?> Total
- Score: =number_format($Score * 100, 1)?>
+ Score: =number_format($Score * 100, 1)?>
|
=number_format($UpVotes / $TotalVotes * 100, 1)?>% positive
diff --git a/sections/torrents/voter_picks.php b/sections/torrents/voter_picks.php
index 457a8f87..0c949dd4 100644
--- a/sections/torrents/voter_picks.php
+++ b/sections/torrents/voter_picks.php
@@ -19,7 +19,7 @@
GROUP BY v.GroupID
HAVING Ups > 0");
$VotePairs = $DB->to_array('GroupID', MYSQL_ASSOC, false);
- $Cache->cache_value('vote_pairs_'.$GroupID, $VotePairs);
+ $Cache->cache_value('vote_pairs_'.$GroupID, $VotePairs, 21600);
}
$GroupScores = array();
@@ -27,7 +27,7 @@
// Cutting out the junk should speed the sort significantly
$Score = binomial_score($RatingGroup['Ups'], $RatingGroup['Total']);
if ($Score > 0.3) {
- $GroupScores[$RatingGroup['GroupID']] = binomial_score($RatingGroup['Ups'], $RatingGroup['Total']);
+ $GroupScores[$RatingGroup['GroupID']] = $Score;
}
}
diff --git a/static/styles/anorex/style.css b/static/styles/anorex/style.css
index 0a95b66e..929ffe27 100644
--- a/static/styles/anorex/style.css
+++ b/static/styles/anorex/style.css
@@ -846,3 +846,19 @@ div[class~=tooltipster-base] {
div[class~=tooltipster-content] > a {
}
+
+.post_id {
+ font-weight: normal;
+}
+
+.vote_tag_up, .vote_artist_up, .vote_album_up {
+ color: green;
+}
+
+.vote_tag_down, .vote_artist_down, .vote_album_down {
+ color: red;
+}
+
+.colhead_dark .time {
+ font-weight: normal;
+}
diff --git a/static/styles/global.css b/static/styles/global.css
index db3452d3..0d131547 100644
--- a/static/styles/global.css
+++ b/static/styles/global.css
@@ -613,11 +613,9 @@ tr.torrent .bookmark>a:after {
}
.vote_tag_up, .vote_artist_up, .vote_album_up {
- color: green;
font-weight: bolder;
}
.vote_tag_down, .vote_artist_down, .vote_album_down {
- color: red;
font-weight: bolder;
}
diff --git a/static/styles/kuro/style.css b/static/styles/kuro/style.css
index 21166058..ece78f6e 100644
--- a/static/styles/kuro/style.css
+++ b/static/styles/kuro/style.css
@@ -926,3 +926,15 @@ tr.torrent .bookmark > a:after { color:#999; }
.autocomplete-suggestions {
background: #222;
}
+
+.post_id {
+ font-weight: normal;
+}
+
+.vote_tag_up, .vote_artist_up, .vote_album_up {
+ color: green;
+}
+
+.vote_tag_down, .vote_artist_down, .vote_album_down {
+ color: red;
+}
diff --git a/static/styles/layer_cake/style.css b/static/styles/layer_cake/style.css
index 67ff6ea1..edad4982 100644
--- a/static/styles/layer_cake/style.css
+++ b/static/styles/layer_cake/style.css
@@ -803,3 +803,15 @@ tr.torrent .bookmark > a:after {
div[class~=tooltipster-content] > a {
color: #AAAAAA;
}
+
+.post_id {
+ font-weight: normal;
+}
+
+.vote_tag_up, .vote_artist_up, .vote_album_up {
+ color: green;
+}
+
+.vote_tag_down, .vote_artist_down, .vote_album_down {
+ color: red;
+}
diff --git a/static/styles/postmod/style.css b/static/styles/postmod/style.css
index 90beff5f..5d4e46e9 100644
--- a/static/styles/postmod/style.css
+++ b/static/styles/postmod/style.css
@@ -1104,3 +1104,11 @@ div[class~=tooltipster-content] > a {
#settings_sections #submit, #settings_sections #settings_search {
margin: 3px 0;
}
+
+.vote_tag_up, .vote_artist_up, .vote_album_up {
+ color: green;
+}
+
+.vote_tag_down, .vote_artist_down, .vote_album_down {
+ color: red;
+}