diff --git a/codepot/src/codepot/controllers/site.php b/codepot/src/codepot/controllers/site.php index d34dae11..2d214e5d 100644 --- a/codepot/src/codepot/controllers/site.php +++ b/codepot/src/codepot/controllers/site.php @@ -104,8 +104,15 @@ class Site extends Controller $login['id'], $this->issuehelper->_get_open_status_array($this->lang), 0); } + // TODO: make count_limit configurable instead of using 20 + $commit_counts_per_project = $this->logs->countCodeCommitsPerProject ('', 0, 20); + $commit_counts_per_user = $this->logs->countCodeCommitsPerUser ('', 0, 20); + if (/*$issues === FALSE || $recently_resolved_issues === FALSE ||*/ - $open_issue_counts_per_project === FALSE || $your_open_issue_counts_per_project === FALSE) + $open_issue_counts_per_project === FALSE || + $your_open_issue_counts_per_project === FALSE || + $commit_counts_per_project === FALSE || + $commit_counts_per_user === FALSE) { $data['login'] = $login; $data['message'] = 'DATABASE ERROR'; @@ -121,6 +128,8 @@ class Site extends Controller $data['recently_resolved_issues'] = $recently_resolved_issues;*/ $data['open_issue_counts_per_project'] = $open_issue_counts_per_project; $data['your_open_issue_counts_per_project'] = $your_open_issue_counts_per_project; + $data['commit_counts_per_project'] = $commit_counts_per_project; + $data['commit_counts_per_user'] = $commit_counts_per_user; $data['issue_type_array'] = $this->issuehelper->_get_type_array($this->lang); $data['issue_status_array'] = $this->issuehelper->_get_status_array($this->lang); $data['issue_priority_array'] = $this->issuehelper->_get_priority_array($this->lang); diff --git a/codepot/src/codepot/language/english/common_lang.php b/codepot/src/codepot/language/english/common_lang.php index b82181e8..1126b79b 100644 --- a/codepot/src/codepot/language/english/common_lang.php +++ b/codepot/src/codepot/language/english/common_lang.php @@ -109,6 +109,8 @@ $lang['System'] = 'System'; $lang['Tag'] = 'Tag'; $lang['Text'] = 'Text'; $lang['Time'] = 'Time'; +$lang['Top committers'] = 'Top committers'; +$lang['Top projects'] = 'Top projects'; $lang['Type'] = 'Type'; $lang['Undo'] = 'Undo'; $lang['Unzip a zip file'] = 'Unzip a zip file'; diff --git a/codepot/src/codepot/language/indonesian/common_lang.php b/codepot/src/codepot/language/indonesian/common_lang.php index ef58382d..a93d9b86 100644 --- a/codepot/src/codepot/language/indonesian/common_lang.php +++ b/codepot/src/codepot/language/indonesian/common_lang.php @@ -108,6 +108,8 @@ $lang['System'] = 'Sistem'; $lang['Tag'] = 'Label'; $lang['Text'] = 'Teks'; $lang['Time'] = 'Waktu'; +$lang['Top committers'] = 'Top committers'; +$lang['Top projects'] = 'Top projects'; $lang['Type'] = 'Type'; $lang['Undo'] = 'Undo'; $lang['Unzip a zip file'] = 'Unzip a zip file'; diff --git a/codepot/src/codepot/language/korean/common_lang.php b/codepot/src/codepot/language/korean/common_lang.php index 3091b7cb..8d33ec1e 100644 --- a/codepot/src/codepot/language/korean/common_lang.php +++ b/codepot/src/codepot/language/korean/common_lang.php @@ -109,6 +109,8 @@ $lang['System'] = '시스템'; $lang['Tag'] = '태그'; $lang['Text'] = '본문'; $lang['Time'] = '시간'; +$lang['Top committers'] = '톱 커미터'; +$lang['Top projects'] = '톱 프로젝트'; $lang['Type'] = '종류'; $lang['Undo'] = '되돌림'; $lang['Unzip a zip file'] = 'zip파일 풀기'; diff --git a/codepot/src/codepot/models/logmodel.php b/codepot/src/codepot/models/logmodel.php index 7d434f28..7995e9cd 100644 --- a/codepot/src/codepot/models/logmodel.php +++ b/codepot/src/codepot/models/logmodel.php @@ -214,6 +214,70 @@ class LogModel extends Model return TRUE; } } + + function countCodeCommitsPerProject ($userid, $hour_limit = 0, $count_limit = 0) + { + $this->db->trans_begin (); + if (strlen($userid) > 0) $this->db->where ('userid', $userid); + + if ($hour_limit > 0) + { + //$this->db->where ("updatedon >= SYSDATE() - INTERVAL {$hour_limit} HOUR"); + $this->db->where ("createdon >= CURRENT_TIMESTAMP - INTERVAL '{$hour_limit}' HOUR"); + } + + $this->db->where ('type', 'code'); + $this->db->where ('action', 'commit'); + + if ($count_limit > 0) $this->db->limit ($count_limit); + + $this->db->select ('projectid, COUNT(id) AS commit_count'); + $this->db->group_by ('projectid'); + if ($count_limit > 0) $this->db->order_by ('commit_count', 'desc'); + $query = $this->db->get ('log'); + if ($this->db->trans_status() === FALSE) + { + $this->errmsg = $this->db->_error_message(); + $this->db->trans_rollback (); + return FALSE; + } + + $this->db->trans_commit(); + + return $query->result (); + } + + function countCodeCommitsPerUser ($projectid, $hour_limit = 0, $count_limit = 0) + { + $this->db->trans_begin (); + if (strlen($projectid) > 0) $this->db->where ('projectid', $projectid); + + if ($hour_limit > 0) + { + //$this->db->where ("updatedon >= SYSDATE() - INTERVAL {$hour_limit} HOUR"); + $this->db->where ("createdon >= CURRENT_TIMESTAMP - INTERVAL '{$hour_limit}' HOUR"); + } + + $this->db->where ('type', 'code'); + $this->db->where ('action', 'commit'); + + if ($count_limit > 0) $this->db->limit ($count_limit); + + $this->db->select ('userid, COUNT(id) AS commit_count'); + $this->db->group_by ('userid'); + if ($count_limit > 0) $this->db->order_by ('commit_count', 'desc'); + $query = $this->db->get ('log'); + if ($this->db->trans_status() === FALSE) + { + $this->errmsg = $this->db->_error_message(); + $this->db->trans_rollback (); + return FALSE; + } + + $this->db->trans_commit(); + + return $query->result (); + } } ?> diff --git a/codepot/src/codepot/views/code_file.php b/codepot/src/codepot/views/code_file.php index 411b0ee6..90a17d72 100644 --- a/codepot/src/codepot/views/code_file.php +++ b/codepot/src/codepot/views/code_file.php @@ -333,10 +333,12 @@ $(function () { $(document).keydown (function(event) { if (event.keyCode == 37) { + // left-arrow on_prev_pdf_page(); } else if (event.keyCode == 39) { + // right-arrow on_next_pdf_page(); } }); diff --git a/codepot/src/codepot/views/project_home.php b/codepot/src/codepot/views/project_home.php index d9420bea..26eaa381 100644 --- a/codepot/src/codepot/views/project_home.php +++ b/codepot/src/codepot/views/project_home.php @@ -228,7 +228,7 @@ foreach ($urls as $url) print '