diff --git a/codepot/src/codepot/controllers/code.php b/codepot/src/codepot/controllers/code.php index e8244627..30c2af10 100644 --- a/codepot/src/codepot/controllers/code.php +++ b/codepot/src/codepot/controllers/code.php @@ -920,6 +920,7 @@ class Code extends Controller { $this->load->model ('ProjectModel', 'projects'); $this->load->model ('SubversionModel', 'subversion'); + $this->load->model ('CodeModel', 'code'); $login = $this->login->getUser (); if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') @@ -960,17 +961,25 @@ class Code extends Controller } else { + if (array_key_exists('history', $file)) { - // Inject the codepot defined tag. + // Inject the codepot defined tag and review count foreach ($file['history'] as &$h) { if (array_key_exists('rev', $h)) { $h['tag'] = $this->subversion->getRevProp ($projectid, $h['rev'], CODEPOT_SVN_TAG_PROPERTY); if ($h['tag'] === FALSE) $h['tag'] = ''; + + $h['review_count'] = $this->code->countReviews ($projectid, $h['rev']); + if ($h['review_count'] === FALSE) $h['review_count'] = 0; + } + else + { + $h['tag'] = ''; + $h['review_count'] = 0; } - else $h['tag'] = ''; } } @@ -984,6 +993,8 @@ class Code extends Controller $data['next_revision'] = $this->subversion->getNextRev ($projectid, $path, $rev); + $data['review_count'] = + $this->load->view ($this->VIEW_HISTORY, $data); } } diff --git a/codepot/src/codepot/models/codemodel.php b/codepot/src/codepot/models/codemodel.php index c9da28e4..e0111acd 100644 --- a/codepot/src/codepot/models/codemodel.php +++ b/codepot/src/codepot/models/codemodel.php @@ -81,6 +81,30 @@ class CodeModel extends Model return $result; } + function countReviews ($projectid, $revision) + { + $this->db->trans_begin (); + + $this->db->where ('projectid', (string)$projectid); + $this->db->where ('rev', $revision); + $this->db->select ('count(*) as count'); + $query = $this->db->get ('code_review'); + if ($this->db->trans_status() === FALSE) + { + $this->errmsg = $this->db->_error_message(); + $this->db->trans_rollback (); + return FALSE; + } + + $result = $query->result(); + $num = empty($result)? 0: + isset($result[0]->COUNT)? $result[0]->COUNT: $result[0]->count; + + $this->db->trans_commit(); + return $num; + } + + function insertReview ($projectid, $revision, $userid, $comment) { // TODO: check if userid can do this.. diff --git a/codepot/src/codepot/views/code_history.php b/codepot/src/codepot/views/code_history.php index 178b6faa..d37c59ce 100644 --- a/codepot/src/codepot/views/code_history.php +++ b/codepot/src/codepot/views/code_history.php @@ -158,6 +158,12 @@ $this->load->view ( print ''; print '