/** * 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 testSetRowsExistingRowsShouldBeReplaced() { $table = new VcsStats_Report_Element_Table(); $table->addRow(array('Value 0a', 'Value 0b', 'Value 0c')); $rows = array(array('Value 1a', 'Value 1b', 'Value 1c'), array('Value 2a', 'Value 2b', 'Value 2c'), array('Value 3a', 'Value 3b', 'Value 3c')); $table->setRows($rows); $this->assertSame($rows, $table->getRows()); }