public static function getMostEditArticles72()
 {
     global $wgUser;
     wfProfileIn(__METHOD__);
     if ($wgUser->isAllowed('corporatepagemanager')) {
         // NOTE: If you update the values here, make sure they're still being purged
         // in extensions/wikia/WikiaStats/WikiaStatistic.php/WikiaGlobalStats::excludeArticle
         $out = WikiaGlobalStats::getPagesEditors(3, 10, true, true);
     } else {
         $out = WikiaGlobalStats::getPagesEditors(3);
     }
     $level = 1;
     $outLevel = 1;
     foreach ($out as $key => $value) {
         $out[$key]['level'] = $outLevel;
         $out[$key]['real_pagename'] = $out[$key]['page_name'];
         $out[$key]['page_name'] = urldecode(str_replace('_', ' ', $out[$key]['page_name']));
         if (empty($out[$key]['out_of_limit'])) {
             $level++;
             if ($out[$key]['count'] != $out[$key + 1]['count']) {
                 $outLevel = $level;
             }
         } else {
             $out[$key]['level'] = 'x';
         }
     }
     wfProfileOut(__METHOD__);
     return $out;
 }
 static function blockArticle()
 {
     global $wgUser, $wgExternalDatawareDB, $wgRequest;
     $response = new AjaxResponse();
     if (!$wgUser->isAllowed('corporatepagemanager') || !$wgRequest->wasPosted()) {
         $response->addText(json_encode(array('status' => "ERROR1")));
         return $response;
     }
     $dbw = wfGetDB(DB_MASTER, array(), $wgExternalDatawareDB);
     $dbw->begin();
     $article = $wgRequest->getVal('wiki') . ":" . $wgRequest->getVal('name');
     if (!WikiaGlobalStats::excludeArticle($article)) {
         $response->addText(json_encode(array('status' => "ERROR2")));
         return $response;
     }
     $response->addText(json_encode(array('status' => "OK")));
     $dbw->commit();
     return $response;
 }
Example #3
0
function wfEditStats($options = array())
{
    global $wgExternalDatawareDB, $wgDBname;
    $m = array();
    $count_edits = $count_content_edits = 0;
    $count_editors = $count_content_editors = 0;
    $count_anons = $count_content_anons = 0;
    $dbr = wfGetDB(DB_SLAVE, 'blobs', $wgExternalDatawareDB);
    ###################
    wfOut("\nCounting total edits...");
    $conditions = array("pe_date" => $options['date']);
    $oRow = $dbr->selectRow(array("page_edits"), array("sum(pe_all_count) as all_count"), $conditions, __METHOD__);
    if ($oRow) {
        $count_edits = intval($oRow->all_count);
    }
    ###################
    wfOut("\nCounting total content namespaces edits...");
    $conditions['pe_is_content'] = 1;
    $oRow = $dbr->selectRow(array("page_edits"), array("sum(pe_all_count) as all_count"), $conditions, __METHOD__);
    if ($oRow) {
        $count_content_edits = intval($oRow->all_count);
    }
    ###################
    wfOut("\nCounting total editors...");
    $conditions = array("pc_date" => $options['date']);
    $oRow = $dbr->selectRow(array("page_editors"), array("sum(pc_all_count) as all_count"), $conditions, __METHOD__);
    if ($oRow) {
        $count_editors = intval($oRow->all_count);
    }
    ###################
    wfOut("\nCounting total content editors...");
    $conditions['pc_is_content'] = 1;
    $oRow = $dbr->selectRow(array("page_editors"), array("sum(pc_all_count) as all_count"), $conditions, __METHOD__);
    if ($oRow) {
        $count_content_editors = intval($oRow->all_count);
    }
    ###################
    wfOut("\nCounting total anons...");
    $conditions = array("pc_date" => $options['date'], "pc_user_id" => 0);
    $oRow = $dbr->selectRow(array("page_editors"), array("sum(pc_all_count) as all_count"), $conditions, __METHOD__);
    if ($oRow) {
        $count_anons = intval($oRow->all_count);
    }
    ###################
    wfOut("\nCounting total content editors...");
    $conditions['pc_is_content'] = 1;
    $oRow = $dbr->selectRow(array("page_editors"), array("sum(pc_all_count) as all_count"), $conditions, __METHOD__);
    if ($oRow) {
        $count_content_anons = intval($oRow->all_count);
    }
    ###################
    wfOut("\nUpdating page statistics...");
    $dbw = wfGetDB(DB_MASTER, array(), $wgExternalDatawareDB);
    $values = array('pe_edits' => $count_edits, 'pe_content_edits' => $count_content_edits, 'pe_editors' => $count_editors, 'pe_content_editors' => $count_content_editors, 'pe_anon_editors' => $count_anons, 'pe_anon_content_editors' => $count_content_anons);
    $conds = array('pe_date' => $options['date']);
    $dbw->delete('page_edits_month', $conds, __METHOD__);
    $dbw->insert('page_edits_month', array_merge($values, $conds), __METHOD__);
    ###################
    # make other stats
    wfOut("\nRegenerate editors/pages statistics to memc...(for home page stats) ");
    for ($i = 1; $i <= 7; $i++) {
        wfOut("\nTop 10 most edited pages (per editors) in last {$i} days  ... ");
        WikiaGlobalStats::getPagesEditors($i, 10, true, true, false, true);
        WikiaGlobalStats::getPagesEditors($i, 10, true, false, false, true);
        wfOut("\nTop 5 most edited pages (per editors) in last {$i} days ... ");
        WikiaGlobalStats::getPagesEditors($i, 5, true, true, false, true);
        WikiaGlobalStats::getPagesEditors($i, 5, true, false, false, true);
    }
    for ($i = 1; $i <= 7; $i++) {
        wfOut("\nTop 10 most edited pages in last {$i} days  ... ");
        WikiaGlobalStats::getEditedArticles($i, 10, true, true);
        wfOut("\nTop 5 most edited pages in last {$i} days ... ");
        WikiaGlobalStats::getEditedArticles($i, 5, true, true);
        wfOut("\\Number of words in last {$i} days ... ");
        WikiaGlobalStats::countWordsInLastDays($i, 1);
    }
    #$memkey = wfMemcKey( "WS:getPagesEditors", 3, 10, 1, 0, 0 );
    #echo "memkey = $memkey \n";
    #echo print_r( $wgMemc->get( $memkey ), true );
    wfOut("\ndone.\n");
}