/** * Computes the number of revisions commited by each user * * @param int $startRevision First revision to work on * @param int $endRevision Last revision to work on * @return array Computed data */ protected function _computeRevisionsCountByAuthor($startRevision, $endRevision) { VcsStats_Runner_Cli::displayMessage('Calculating revisions count by author'); $table = new VcsStats_Report_Element_Table(); $table->setCode('revisions_count_by_author'); $table->setTitle('Revisions count by author'); $table->addColumn(new VcsStats_Report_Element_Table_Column('Author', 'author')); $table->addColumn(new VcsStats_Report_Element_Table_Column('Count', 'count', VcsStats_Report_Element_Table_Column::ALIGNMENT_RIGHT)); $where = ''; if (null !== $startRevision && null != $endRevision) { $where = "WHERE id >= {$startRevision} AND id <= {$endRevision}"; } $sql = "SELECT author, COUNT(*) AS count\n FROM revisions\n {$where}\n GROUP BY author\n ORDER BY count DESC"; $data = $this->_cache->fetchAll($sql); $table->setRows($data); return $table; }
public function testSetColumnsExistingColumnsShouldBeReplaced() { $table = new VcsStats_Report_Element_Table(); $table->addColumn(new VcsStats_Report_Element_Table_Column('Column 0', 'col0')); $columns = array(new VcsStats_Report_Element_Table_Column('Column 1', 'col1'), new VcsStats_Report_Element_Table_Column('Column 2', 'col2'), new VcsStats_Report_Element_Table_Column('Column 3', 'col3')); $table->setColumns($columns); $this->assertSame($columns, $table->getColumns()); }