mirror of
https://github.com/WhatCD/Gazelle.git
synced 2024-12-12 18:36:29 +00:00
Empty commit
This commit is contained in:
parent
624fe947be
commit
608fe98b6a
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
?>
|
||||
<table class="layout" width="100%">
|
||||
<tr>
|
||||
<td align="left"><strong><a href="#" onclick="$('#debug_perf').gtoggle(); return false;" class="brackets">View</a> Performance stats:</strong></td>
|
||||
<td align="left"><strong><a href="#" onclick="$(this).parents('.layout').next('#debug_perf').gtoggle(); return false;" class="brackets">View</a> Performance stats:</strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table id="debug_perf" class="debug_table hidden" width="100%">
|
||||
@ -333,7 +341,7 @@ public function include_table($Includes = false) {
|
||||
?>
|
||||
<table class="layout" width="100%">
|
||||
<tr>
|
||||
<td align="left"><strong><a href="#" onclick="$('#debug_include').gtoggle(); return false;" class="brackets">View</a> <?=number_format(count($Includes))?> Includes:</strong></td>
|
||||
<td align="left"><strong><a href="#" onclick="$(this).parents('.layout').next('#debug_include').gtoggle(); return false;" class="brackets">View</a> <?=number_format(count($Includes))?> Includes:</strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table id="debug_include" class="debug_table hidden" width="100%">
|
||||
@ -357,7 +365,7 @@ public function class_table($Classes = false) {
|
||||
?>
|
||||
<table class="layout" width="100%">
|
||||
<tr>
|
||||
<td align="left"><strong><a href="#" onclick="$('#debug_classes').gtoggle(); return false;" class="brackets">View</a> Classes:</strong></td>
|
||||
<td align="left"><strong><a href="#" onclick="$(this).parents('.layout').next('#debug_classes').gtoggle(); return false;" class="brackets">View</a> Classes:</strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table id="debug_classes" class="debug_table hidden" width="100%">
|
||||
@ -374,7 +382,7 @@ public function extension_table() {
|
||||
?>
|
||||
<table class="layout" width="100%">
|
||||
<tr>
|
||||
<td align="left"><strong><a href="#" onclick="$('#debug_extensions').gtoggle(); return false;" class="brackets">View</a> Extensions:</strong></td>
|
||||
<td align="left"><strong><a href="#" onclick="$(this).parents('.layout').next('#debug_extensions').gtoggle(); return false;" class="brackets">View</a> Extensions:</strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table id="debug_extensions" class="debug_table hidden" width="100%">
|
||||
@ -397,7 +405,7 @@ public function flag_table($Flags = false) {
|
||||
?>
|
||||
<table class="layout" width="100%">
|
||||
<tr>
|
||||
<td align="left"><strong><a href="#" onclick="$('#debug_flags').gtoggle(); return false;" class="brackets">View</a> Flags:</strong></td>
|
||||
<td align="left"><strong><a href="#" onclick="$(this).parents('.layout').next('#debug_flags').gtoggle(); return false;" class="brackets">View</a> Flags:</strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table id="debug_flags" class="debug_table hidden" width="100%">
|
||||
@ -435,7 +443,7 @@ public function constant_table($Constants = false) {
|
||||
?>
|
||||
<table class="layout" width="100%">
|
||||
<tr>
|
||||
<td align="left"><strong><a href="#" onclick="$('#debug_constants').gtoggle(); return false;" class="brackets">View</a> Constants:</strong></td>
|
||||
<td align="left"><strong><a href="#" onclick="$(this).parents('.layout').next('#debug_constants').gtoggle(); return false;" class="brackets">View</a> Constants:</strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table id="debug_constants" class="debug_table hidden" width="100%">
|
||||
@ -462,7 +470,7 @@ public function cache_table($CacheKeys = false) {
|
||||
?>
|
||||
<table class="layout" width="100%">
|
||||
<tr>
|
||||
<td align="left"><strong><a href="#" onclick="$('#debug_cache').gtoggle(); return false;" class="brackets">View</a><?=$Header?></strong></td>
|
||||
<td align="left"><strong><a href="#" onclick="$(this).parents('.layout').next('#debug_cache').gtoggle(); return false;" class="brackets">View</a><?=$Header?></strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table id="debug_cache" class="debug_table hidden" width="100%">
|
||||
@ -491,7 +499,7 @@ public function error_table($Errors = false) {
|
||||
?>
|
||||
<table class="layout" width="100%">
|
||||
<tr>
|
||||
<td align="left"><strong><a href="#" onclick="$('#debug_error').gtoggle(); return false;" class="brackets">View</a> <?=number_format(count($Errors))?> Errors:</strong></td>
|
||||
<td align="left"><strong><a href="#" onclick="$(this).parents('.layout').next('#debug_error').gtoggle(); return false;" class="brackets">View</a> <?=number_format(count($Errors))?> Errors:</strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table id="debug_error" class="debug_table hidden" width="100%">
|
||||
@ -530,14 +538,16 @@ public function query_table($Queries=false) {
|
||||
?>
|
||||
<table class="layout" width="100%">
|
||||
<tr>
|
||||
<td align="left"><strong><a href="#" onclick="$('#debug_database').gtoggle(); return false;" class="brackets">View</a><?=$Header?></strong></td>
|
||||
<td align="left"><strong><a href="#" onclick="$(this).parents('.layout').next('#debug_database').gtoggle(); return false;" class="brackets">View</a><?=$Header?></strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table id="debug_database" class="debug_table hidden" width="100%">
|
||||
<?
|
||||
foreach ($Queries as $Query) {
|
||||
list($SQL, $Time, $Warnings) = $Query;
|
||||
$Warnings = implode('<br />', $Warnings);
|
||||
if ($Warnings !== null) {
|
||||
$Warnings = implode('<br />', $Warnings);
|
||||
}
|
||||
?>
|
||||
<tr valign="top">
|
||||
<td class="debug_data debug_query_data"><div><?=str_replace("\t", ' ', nl2br(display_str($SQL)))?></div></td>
|
||||
@ -564,7 +574,7 @@ public function sphinx_table($Queries = false) {
|
||||
?>
|
||||
<table class="layout" width="100%">
|
||||
<tr>
|
||||
<td align="left"><strong><a href="#" onclick="$('#debug_sphinx').gtoggle(); return false;" class="brackets">View</a><?=$Header?></strong></td>
|
||||
<td align="left"><strong><a href="#" onclick="$(this).parents('.layout').next('#debug_sphinx').gtoggle(); return false;" class="brackets">View</a><?=$Header?></strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table id="debug_sphinx" class="debug_table hidden" width="100%">
|
||||
@ -596,7 +606,7 @@ public function vars_table($Vars = false) {
|
||||
?>
|
||||
<table class="layout" width="100%">
|
||||
<tr>
|
||||
<td align="left"><strong><a href="#" onclick="$('#debug_loggedvars').gtoggle(); return false;" class="brackets">View</a><?=$Header?></strong></td>
|
||||
<td align="left"><strong><a href="#" onclick="$(this).parents('.layout').next('#debug_loggedvars').gtoggle(); return false;" class="brackets">View</a><?=$Header?></strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table id="debug_loggedvars" class="debug_table hidden" width="100%">
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -237,10 +237,14 @@
|
||||
|
||||
<span class="favoritecount_small tooltip" title="<?=$DownVotes . ($DownVotes == 1 ? ' downvote' : ' downvotes')?>"><span id="downvotes"><?=number_format($DownVotes)?></span> <span class="vote_album_down">∨</span></span>
|
||||
|
||||
<span class="favoritecount_small" id="totalvotes"><?=number_format($TotalVotes)?></span> Total
|
||||
<span style="float: right;"><span class="favoritecount_small" id="totalvotes"><?=number_format($TotalVotes)?></span> Total</span>
|
||||
</span>
|
||||
<br />
|
||||
<span class="tooltip_interactive" title="<span style="font-weight: bold;">Score: <?=number_format($Score * 100, 4)?></span><br /><br />This is the lower bound of the binomial confidence interval <a href="wiki.php?action=article&id=1037">described here</a> multiplied by 100.">Score: <span class="favoritecount_small"><?=number_format($Score * 100, 1)?></span></span>
|
||||
<span style="white-space: nowrap;">
|
||||
<span class="tooltip_interactive" title="<span style="font-weight: bold;">Score: <?=number_format($Score * 100, 4)?></span><br /><br />This is the lower bound of the binomial confidence interval <a href="wiki.php?action=article&id=1037">described here</a>, multiplied by 100." data-title-plain="Score: <?=number_format($Score * 100, 4)?>. This is the lower bound of the binomial confidence interval described in the Favorite Album Votes wiki article, multiplied by 100.">Score: <span class="favoritecount_small"><?=number_format($Score * 100, 1)?></span></span>
|
||||
|
|
||||
<span class="favoritecount_small"><?=number_format($UpVotes / $TotalVotes * 100, 1)?>%</span> positive
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<?
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
<span class="favoritecount" id="totalvotes"><?=number_format($TotalVotes)?></span> Total
|
||||
<br /><br />
|
||||
<span class="tooltip_interactive" title="<span style="font-weight: bold;">Score: <?=number_format($Score * 100, 4)?></span><br /><br />This is the lower bound of the binomial confidence interval <a href="wiki.php?action=article&id=1037">described here</a> multiplied by 100.">Score: <span class="favoritecount"><?=number_format($Score * 100, 1)?></span></span>
|
||||
<span class="tooltip_interactive" title="<span style="font-weight: bold;">Score: <?=number_format($Score * 100, 4)?></span><br /><br />This is the lower bound of the binomial confidence interval <a href="wiki.php?action=article&id=1037">described here</a>, multiplied by 100." data-title-plain="Score: <?=number_format($Score * 100, 4)?>. This is the lower bound of the binomial confidence interval described in the Favorite Album Votes wiki article, multiplied by 100.">Score: <span class="favoritecount"><?=number_format($Score * 100, 1)?></span></span>
|
||||
|
|
||||
<span class="favoritecount"><?=number_format($UpVotes / $TotalVotes * 100, 1)?>%</span> positive
|
||||
<br /><br />
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user