Project

General

Profile

Alter /views/reports/_details.rhtml

Added by Johan Olsson over 14 years ago

Hi!

I have made a plugin that removes some of the columns in the details view and it works great.

Now I'am trying to add some extra columns, like how many open issues are assigned and not assigned.

I thought this code should count all issues that are open and not assigned, but it just counts all open issues.

[code]
<%= aggregate_link data, { field_name => row.id, "assigned_to_id" => nil },
:controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : Herve Harster)),
:set_filter => 1,
"#{field_name}" => row.id,
"status_id" => "*" %>

(Never worked with Ruby on Rails or Redmine before...)


Replies (1)

RE: Alter /views/reports/_details.rhtml - Added by Johan Olsson over 14 years ago

I solved it by adding two SQL queries in the view (ugly, but works...).

[code]
<% @all_unsigned_issues ||=
ActiveRecord::Base.connection.select_all("select i.status_id as status, s.is_closed as closed, t.id as tracker_id, count(i.id) as total
from
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{Tracker.table_name} t
where
i.assigned_to_id is null
and i.project_id=#{@project.id}
and i.status_id=s.id
and i.tracker_id=t.id
group by i.id") %>

[code]
<% @all_assigned_issues ||=
ActiveRecord::Base.connection.select_all("select i.status_id as status, s.is_closed as closed, t.id as tracker_id, count(i.id) as total
from
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{Tracker.table_name} t
where
i.assigned_to_id is not null
and i.project_id=#{@project.id}
and i.status_id=s.id
and i.tracker_id=t.id
group by i.id") %>

Then:

[code]
<%= aggregate_link @all_unsigned_issues, { field_name => row.id, "status" => 5 },
:controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : Herve Harster)),
:set_filter => 1,
"#{field_name}" => row.id,
"status_id" => 5 %>

[code]
<%= aggregate_link @all_assigned_issues, { field_name => row.id, "status" => 5 },
:controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : Herve Harster)),
:set_filter => 1,
"#{field_name}" => row.id,
"status_id" => 5 %>

    (1-1/1)