function execute() { global $wgOut, $wgLang; $stats = RepoStats::newFromRepo($this->mRepo); $repoName = $this->mRepo->getName(); $wgOut->wrapWikiMsg('<h2 id="stats-main">$1</h2>', array('code-stats-header', $repoName)); $wgOut->addWikiMsg('code-stats-main', $wgLang->timeanddate($stats->time, true), $wgLang->formatNum($stats->revisions), $repoName, $wgLang->formatNum($stats->authors), $wgLang->time($stats->time, true), $wgLang->date($stats->time, true)); if (!empty($stats->states)) { $wgOut->wrapWikiMsg('<h3 id="stats-revisions">$1</h3>', 'code-stats-status-breakdown'); $wgOut->addHTML('<table class="wikitable">' . '<tr><th>' . wfMsgHtml('code-field-status') . '</th><th>' . wfMsgHtml('code-stats-count') . '</th></tr>'); foreach (CodeRevision::getPossibleStates() as $state) { $count = isset($stats->states[$state]) ? $stats->states[$state] : 0; $count = htmlspecialchars($wgLang->formatNum($count)); $link = Linker::link(SpecialPage::getTitleFor('Code', $repoName . '/status/' . $state), htmlspecialchars($this->statusDesc($state))); $wgOut->addHTML("<tr><td>{$link}</td>" . "<td class=\"mw-codereview-status-{$state}\">{$count}</td></tr>"); } $wgOut->addHTML('</table>'); } if (!empty($stats->fixmes)) { $this->writeAuthorStatusTable('fixme', $stats->fixmes); } if (!empty($stats->new)) { $this->writeAuthorStatusTable('new', $stats->new); } if (!empty($stats->fixmesPerPath)) { $this->writeStatusPathTable('fixme', $stats->fixmesPerPath); } if (!empty($stats->newPerPath)) { $this->writeStatusPathTable('new', $stats->newPerPath); } }
/** * @param CodeRepository $repo * @return RepoStats */ public static function newFromRepo(CodeRepository $repo) { global $wgMemc, $wgCodeReviewRepoStatsCacheTime; $key = wfMemcKey('codereview1', 'stats', $repo->getName()); $stats = $wgMemc->get($key); wfDebug("{$repo->getName()} repo stats: cache "); if ($stats) { wfDebug("hit\n"); return $stats; } wfDebug("miss\n"); $stats = new RepoStats($repo); $stats->generate(); $wgMemc->set($key, $stats, $wgCodeReviewRepoStatsCacheTime); return $stats; }