コード例 #1
0
<?php

require_once "commandLine.inc";
require_once "extensions/wikihow/Rating/RatingsTool.php";
require_once "extensions/wikihow/Rating/RatingSample.php";
require_once "extensions/wikihow/Rating/RatingArticle.php";
$insertMax = 150;
$dbw = wfGetDB(DB_MASTER);
$dbr = wfGetDB(DB_SLAVE);
$avg = wfMsg('list_bottom_rated_pages_avg');
$minvotes = wfMsg('list_bottom_rated_pages_min_votes');
$cleardays = wfMsg('list_bottom_rated_pages_clear_limit_days');
$ratingTool = new RatingArticle();
$dateDiff = strtotime('now - 1 month');
$res = $dbr->select(array($ratingTool->getTableName()), array("distinct {$ratingTool->getTablePrefix()}page"), array("{$ratingTool->getTablePrefix()}deleted_when > FROM_UNIXTIME('.{$dbw->addQuotes}({$dateDiff}).')"), 'refreshLowRating.php:newlyDeleted');
$newlyDeletedPages = array();
foreach ($res as $row) {
    $newlyDeletedPages[] = $row->{$ratingTool->getTablePrefix() . 'page'};
}
$notin = join(',', $newlyDeletedPages);
$conditions = array("{$ratingTool->getTablePrefix()}page = page_id", "{$ratingTool->getTablePrefix()}isdeleted" => 0, 'page_is_redirect' => 0);
if (!empty($notin)) {
    $notin = "{$ratingTool->getTablePrefix()}page NOT IN (" . $notin . ")";
    $conditions[] = $notin;
}
$dbw->query("delete from rating_low;", 'refreshLowRatings.php:delete');
$res = $dbr->select(array($ratingTool->getTableName(), 'page'), array("{$ratingTool->getTablePrefix()}page", "AVG({$ratingTool->getTablePrefix()}rating) as R", 'count(*) as C'), $conditions, __FILE__, array('GROUP BY' => "{$ratingTool->getTablePrefix()}page"));
$sqlStart = "INSERT into {$ratingTool->getLowTableName()} ({$ratingTool->getLowTablePrefix()}page, {$ratingTool->getLowTablePrefix()}avg, {$ratingTool->getLowTablePrefix()}count) VALUES ";
$sql = $sqlStart;
$count = 0;
foreach ($res as $row) {
コード例 #2
0
ファイル: Rating.body.php プロジェクト: biribogos/wikihow-src
 /**
  *
  * This function can only get called when an article gets deleted
  *
  **/
 function clearRatingsOnDelete($wikiPage, $user, $reason)
 {
     $ratingTool = new RatingArticle();
     $ratingTool->clearRatings($wikiPage->getId(), $user, "Deleting page");
     return true;
 }