Skip to content
Browse files

fix admin stats

  • Loading branch information...
1 parent a4fd799 commit d4acf4e688c219dd1e61509088ed3d28f068627b @mikelbring committed May 26, 2012
View
4 app/application/config/tinyissue.php
@@ -1,6 +1,6 @@
<?php
return array(
- 'release_date' => '2-20-2012',
- 'version' => '1.1.0'
+ 'release_date' => '5-26-2012',
+ 'version' => '1.2.2'
);
View
3 app/application/controllers/administration.php
@@ -17,11 +17,12 @@ public function __construct()
*/
public function get_index()
{
+ $issues = Project\Issue::count_issues();
return $this->layout->with('active', 'dashboard')->nest('content', 'administration.index', array(
'users' => User::where('deleted', '=', 0)->count(),
'active_projects' => Project::where('status', '=', 1)->count(),
'archived_projects' => Project::where('status', '=', 0)->count(),
- 'issues' => Project\Issue::count_issues(),
+ 'issues' => $issues,
));
}
}
View
18 app/application/models/project/issue.php
@@ -364,9 +364,8 @@ public static function create_issue($input, $project)
public static function count_issues()
{
- /* Count Open Issues */
- $sql = '
- SELECT COUNT(i.id) AS total
+ /* Count Open Issues - Project must be open */
+ $sql = 'SELECT COUNT(i.id) AS `total`
FROM projects_issues i
JOIN projects p ON p.id = i.project_id
WHERE p.status = 1 AND i.status = 1
@@ -376,27 +375,26 @@ public static function count_issues()
$count = \DB::first($sql);
$open_issues = !$count ? 0 : $count->total;
- /* Count Closed Issues - If the project is closed, so is the issue */
- $sql = '
- SELECT COUNT(i.id) AS total
+ /* Count Closed Issues - Open Projects */
+ $sql = 'SELECT COUNT(i.id) AS `total`
FROM projects_issues i
JOIN projects p ON p.id = i.project_id
WHERE p.status = 1 AND i.status = 0
GROUP BY i.id
';
- $count = (int) \DB::first($sql);
+ $count = \DB::first($sql);
$closed_issues_open_project = !$count ? 0 : $count->total;
- $sql = '
- SELECT COUNT(i.id) AS total
+ /* Count Issues - Closed Projects */
+ $sql = 'SELECT COUNT(i.id) AS `total`
FROM projects_issues i
JOIN projects p ON p.id = i.project_id
WHERE p.status = 0
GROUP BY i.id
';
- $count = (int) \DB::first($sql);
+ $count = \DB::first($sql);
$issues_closed_project = !$count ? 0 : $count->total;
$closed_issues = ($closed_issues_open_project + $issues_closed_project);

0 comments on commit d4acf4e

Please sign in to comment.
Something went wrong with that request. Please try again.