ApiStatsQuery.php

Go to the documentation of this file.
00001 <?php
00016 abstract class ApiStatsQuery extends ApiQueryBase {
00017     public function getCacheMode( $params ) {
00018         return 'public';
00019     }
00020 
00021     public function execute() {
00022         $params = $this->extractRequestParams();
00023         MessageGroupStats::setTimeLimit( $params['timelimit'] );
00024 
00025         $cache = $this->getData();
00026         $result = $this->getResult();
00027 
00028         foreach ( $cache as $item => $stats ) {
00029             if ( $item < $params['offset'] ) {
00030                 continue;
00031             }
00032 
00033             if ( $stats[MessageGroupStats::TOTAL] === null ) {
00034                 $this->setContinueEnumParameter( 'offset', $item );
00035                 break;
00036             }
00037 
00038             $data = $this->makeItem( $item, $stats );
00039             $result->addValue( array( 'query', $this->getModuleName() ), null, $data );
00040         }
00041 
00042         $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'stats' );
00043     }
00044 
00045     protected function makeItem( $item, $stats ) {
00046         return array(
00047             'total' => $stats[MessageGroupStats::TOTAL],
00048             'translated' => $stats[MessageGroupStats::TRANSLATED],
00049             'fuzzy' => $stats[MessageGroupStats::FUZZY],
00050             'proofread' => $stats[MessageGroupStats::PROOFREAD],
00051         );
00052     }
00053 
00054     public function getAllowedParams() {
00055         return array(
00056             'offset' => array(
00057                 ApiBase::PARAM_DFLT => 0,
00058                 ApiBase::PARAM_TYPE => 'string',
00059             ),
00060             'timelimit' => array(
00061                 ApiBase::PARAM_DFLT => 8,
00062                 ApiBase::PARAM_TYPE => 'integer',
00063                 ApiBase::PARAM_MAX => 10,
00064                 ApiBase::PARAM_MIN => 0,
00065             ),
00066         );
00067     }
00068 
00069     public function getParamDescription() {
00070         return array(
00071             'offset' => 'If not all stats are calculated, you will get a query-continue ' .
00072                 'parameter for offset you can use to get more.',
00073             'timelimit' => 'Maximum time to spend calculating missing statistics. If ' .
00074                 'zero, only the cached results from the beginning are returned.',
00075         );
00076     }
00077 
00078     public function getVersion() {
00079         return __CLASS__ . ': ' . TRANSLATE_VERSION;
00080     }
00081 }
Generated on Tue Oct 29 00:00:23 2013 for MediaWiki Translate Extension by  doxygen 1.6.3