增加统计功能
This commit is contained in:
parent
cfbabf3eac
commit
8e35158fe9
|
@ -583,6 +583,156 @@ class IssuesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def statistics
|
||||||
|
@project = Project.find(params[:id])
|
||||||
|
if @project.nil?
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
retrieve_query
|
||||||
|
sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
|
||||||
|
sort_update(@query.sortable_columns)
|
||||||
|
@query.sort_criteria = sort_criteria.to_a
|
||||||
|
@project_base_tag = 'base_projects'
|
||||||
|
if @query.valid?
|
||||||
|
@tracker_id = params[:tracker_id]
|
||||||
|
@assign_to_id = params[:assigned_to_id]
|
||||||
|
@author_id = params[:author_id]
|
||||||
|
@priority_id = params[:priority_id]
|
||||||
|
@status_id = params[:status_id]
|
||||||
|
@subject = params[:subject]
|
||||||
|
@done_ratio = params[:done_ratio]
|
||||||
|
@fixed_version_id = params[:fixed_version_id]
|
||||||
|
@issue_count = @query.issue_count
|
||||||
|
@test = params[:test]
|
||||||
|
@project_sort = 'issues.updated_on desc'
|
||||||
|
if params[:test] != "0"
|
||||||
|
case @test
|
||||||
|
when "1"
|
||||||
|
@project_sort = 'issues.created_on desc'
|
||||||
|
when "2"
|
||||||
|
@project_sort = 'issues.created_on asc'
|
||||||
|
when "3"
|
||||||
|
@project_sort = 'issues.updated_on desc'
|
||||||
|
when "4"
|
||||||
|
@project_sort = 'issues.updated_on asc'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@issues_filter = @query.issues(:order => @project_sort)
|
||||||
|
|
||||||
|
#统计
|
||||||
|
@results = {}
|
||||||
|
|
||||||
|
#统计total
|
||||||
|
@alltotal = {}
|
||||||
|
for i in 0..5 do
|
||||||
|
@alltotal[i] = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
@opentotal = {}
|
||||||
|
for i in 0..5 do
|
||||||
|
@opentotal[i] = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
@closetotal = {}
|
||||||
|
for i in 0..5 do
|
||||||
|
@closetotal[i] = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
#开启关闭
|
||||||
|
@issue_open_count = 0
|
||||||
|
@issue_close_count = 0
|
||||||
|
|
||||||
|
@issues_filter.each do |issue|
|
||||||
|
@alltotal[0] = @alltotal[0] + 1
|
||||||
|
@alltotal[issue.tracker_id.to_i] = @alltotal[issue.tracker_id.to_i] + 1
|
||||||
|
user_id = issue.assigned_to_id
|
||||||
|
if issue.assigned_to_id.nil?
|
||||||
|
user_id = issue.author_id
|
||||||
|
end
|
||||||
|
|
||||||
|
if !@results[user_id].nil?
|
||||||
|
@results[user_id][0] = @results[user_id][0] + 1
|
||||||
|
@results[user_id][issue.tracker_id.to_i] = @results[user_id][issue.tracker_id.to_i] + 1
|
||||||
|
|
||||||
|
if issue.status_id.to_i == 5
|
||||||
|
@issue_close_count = @issue_close_count + 1
|
||||||
|
@results[user_id][12] = @results[user_id][12]+1
|
||||||
|
@results[user_id][12+issue.tracker_id.to_i] = @results[user_id][12+issue.tracker_id.to_i]+1
|
||||||
|
|
||||||
|
@closetotal[0] = @closetotal[0] + 1
|
||||||
|
@closetotal[issue.tracker_id.to_i] = @closetotal[issue.tracker_id.to_i] + 1
|
||||||
|
else
|
||||||
|
@issue_open_count = @issue_open_count + 1
|
||||||
|
@results[user_id][6] = @results[user_id][6]+1
|
||||||
|
@results[user_id][6+issue.tracker_id.to_i] = @results[user_id][6+issue.tracker_id.to_i]+1
|
||||||
|
|
||||||
|
@opentotal[0] = @opentotal[0] + 1
|
||||||
|
@opentotal[issue.tracker_id.to_i] = @opentotal[issue.tracker_id.to_i] + 1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
|
||||||
|
@results[user_id] = {}
|
||||||
|
|
||||||
|
tmpuser = User.find(user_id)
|
||||||
|
|
||||||
|
@results[user_id][:name] = tmpuser.nil? ? " " : tmpuser.show_name
|
||||||
|
#所有的
|
||||||
|
@results[user_id][0] = 1
|
||||||
|
for i in 1..17 do
|
||||||
|
@results[user_id][i] = 0
|
||||||
|
end
|
||||||
|
# @results[user_id][1] = 0
|
||||||
|
# @results[user_id][2] = 0
|
||||||
|
# @results[user_id][3] = 0
|
||||||
|
# @results[user_id][4] = 0
|
||||||
|
# @results[user_id][5] = 0
|
||||||
|
@results[user_id][issue.tracker_id.to_i] = 1
|
||||||
|
|
||||||
|
#开启的 status_id = 12346
|
||||||
|
# @results[user_id][6] = 0
|
||||||
|
# @results[user_id][7] = 0
|
||||||
|
# @results[user_id][8] = 0
|
||||||
|
# @results[user_id][9] = 0
|
||||||
|
# @results[user_id][10] = 0
|
||||||
|
# @results[user_id][11] = 0
|
||||||
|
|
||||||
|
#关闭的 status_id = 5
|
||||||
|
# @results[user_id][12] = 0
|
||||||
|
# @results[user_id][13] = 0
|
||||||
|
# @results[user_id][14] = 0
|
||||||
|
# @results[user_id][15] = 0
|
||||||
|
# @results[user_id][16] = 0
|
||||||
|
# @results[user_id][17] = 0
|
||||||
|
|
||||||
|
if issue.status_id.to_i == 5
|
||||||
|
@results[user_id][12] = 1
|
||||||
|
@results[user_id][12+issue.tracker_id.to_i] = 1
|
||||||
|
@issue_close_count = @issue_close_count+1
|
||||||
|
|
||||||
|
@closetotal[0] = @closetotal[0] + 1
|
||||||
|
@closetotal[issue.tracker_id.to_i] = @closetotal[issue.tracker_id.to_i] + 1
|
||||||
|
else
|
||||||
|
@issue_open_count = @issue_open_count+1
|
||||||
|
@results[user_id][6] = 1
|
||||||
|
@results[user_id][6+issue.tracker_id.to_i] = 1
|
||||||
|
|
||||||
|
@opentotal[0] = @opentotal[0] + 1
|
||||||
|
@opentotal[issue.tracker_id.to_i] = @opentotal[issue.tracker_id.to_i] + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def find_project
|
def find_project
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<div style="text-align:center;">
|
<div style="text-align:center;">
|
||||||
<a href="<%=project_issues_path(:project_id => @project, :format => 'xls', :export => true, :set_filter => "1")%>" id="sendexcel" class="btn_newpro_grey fl ml15 mt15" alt="导出" onclick="remote_function_export('<%= @project.id %>')">导出</a>
|
<a href="<%=project_issues_path(:project_id => @project, :format => 'xls', :export => true, :set_filter => "1")%>" id="sendexcel" class="btn_newpro_grey fl ml15 mt15" alt="导出" onclick="remote_function_export('<%= @project.id %>')">导出</a>
|
||||||
<a href="#" class="btn_newpro_grey fl ml5 mt15" alt="统计">统计</a>
|
<a onclick="getIssueStatistics('<%= project_issues_statistics_path(@project.id) %>')" class="btn_newpro_grey fl ml5 mt15" alt="统计">统计</a>
|
||||||
<div class="pages fr" style="width:auto; display:inline-block;">
|
<div class="pages fr" style="width:auto; display:inline-block;">
|
||||||
<ul id="issue_list_pagination">
|
<ul id="issue_list_pagination">
|
||||||
<%= pagination_links_full @issue_pages, @issue_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %>
|
<%= pagination_links_full @issue_pages, @issue_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %>
|
||||||
|
|
|
@ -0,0 +1,151 @@
|
||||||
|
|
||||||
|
<div class="myissues_head mb5">
|
||||||
|
<h2 class="ml15">issue统计</h2>
|
||||||
|
</div>
|
||||||
|
<div class="clear mb5">
|
||||||
|
<div class="issues_statistics fl">
|
||||||
|
<ul>
|
||||||
|
<li>所有<a style="cursor: pointer;" onclick="showResultAll();" class="issues_greycirbg_btn "><%= @issues_filter.count %></a></li>
|
||||||
|
<li>开启<a style="cursor: pointer;" onclick="showResultOpen();" class="issues_greycirbg_btn "><%= @issue_open_count %></a></li>
|
||||||
|
<li>关闭<a style="cursor: pointer;" onclick="showResultClose();" class="issues_greycirbg_btn "><%= @issue_close_count %></a></li>
|
||||||
|
</ul>
|
||||||
|
</div><!--issues_statistics end-->
|
||||||
|
<a href="<%= new_project_issue_path(@project)%>" class="sy_btn_green fr " >新建</a>
|
||||||
|
</div>
|
||||||
|
<div id="result_all" class="">
|
||||||
|
<table class="sy_new_table " cellpadding="0" cellspacing="0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td class="dis p10" style="width:166px;">指派给</td>
|
||||||
|
<td class="w130">所有</td>
|
||||||
|
<td class="w130">需求</td>
|
||||||
|
<td class="w130">任务</td>
|
||||||
|
<td class="w130">缺陷</td>
|
||||||
|
<td class="w130">支持</td>
|
||||||
|
<td class="w130">周报</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @results.each do |k,v|%>
|
||||||
|
<tr>
|
||||||
|
<td class="hidden dis p10" style="width:166px;"><%= v[:name] %></td>
|
||||||
|
<td class="w130"><%= v[0] %></td>
|
||||||
|
<td class="w130"><%= v[2] %></td>
|
||||||
|
<td class="w130"><%= v[4] %></td>
|
||||||
|
<td class="w130"><%= v[1] %></td>
|
||||||
|
<td class="w130"><%= v[3] %></td>
|
||||||
|
<td class="w130"><%= v[5] %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<tr>
|
||||||
|
<td class="hidden dis p10" style="width:166px;">Total</td>
|
||||||
|
<td class="w130"><%= @alltotal[0] %></td>
|
||||||
|
<td class="w130"><%= @alltotal[2] %></td>
|
||||||
|
<td class="w130"><%= @alltotal[4] %></td>
|
||||||
|
<td class="w130"><%= @alltotal[1] %></td>
|
||||||
|
<td class="w130"><%= @alltotal[3] %></td>
|
||||||
|
<td class="w130"><%= @alltotal[5] %></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="result_open" style="display: none">
|
||||||
|
<table class="sy_new_table " cellpadding="0" cellspacing="0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td class="dis p10" style="width:166px;">指派给</td>
|
||||||
|
<td class="w130">所有</td>
|
||||||
|
<td class="w130">需求</td>
|
||||||
|
<td class="w130">任务</td>
|
||||||
|
<td class="w130">缺陷</td>
|
||||||
|
<td class="w130">支持</td>
|
||||||
|
<td class="w130">周报</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @results.each do |k,v|%>
|
||||||
|
<% if v[6] > 0 %>
|
||||||
|
<tr>
|
||||||
|
<td class="hidden dis p10" style="width:166px;"><%= v[:name] %></td>
|
||||||
|
<td class="w130"><%= v[6] %></td>
|
||||||
|
<td class="w130"><%= v[8] %></td>
|
||||||
|
<td class="w130"><%= v[10] %></td>
|
||||||
|
<td class="w130"><%= v[7] %></td>
|
||||||
|
<td class="w130"><%= v[9] %></td>
|
||||||
|
<td class="w130"><%= v[11] %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<tr>
|
||||||
|
<td class="hidden dis p10" style="width:166px;">Total</td>
|
||||||
|
<td class="w130"><%= @opentotal[0] %></td>
|
||||||
|
<td class="w130"><%= @opentotal[2] %></td>
|
||||||
|
<td class="w130"><%= @opentotal[4] %></td>
|
||||||
|
<td class="w130"><%= @opentotal[1] %></td>
|
||||||
|
<td class="w130"><%= @opentotal[3] %></td>
|
||||||
|
<td class="w130"><%= @opentotal[5] %></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="result_close" style="display: none">
|
||||||
|
<table class="sy_new_table " cellpadding="0" cellspacing="0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td class="dis p10" style="width:166px;">指派给</td>
|
||||||
|
<td class="w130">所有</td>
|
||||||
|
<td class="w130">需求</td>
|
||||||
|
<td class="w130">任务</td>
|
||||||
|
<td class="w130">缺陷</td>
|
||||||
|
<td class="w130">支持</td>
|
||||||
|
<td class="w130">周报</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @results.each do |k,v|%>
|
||||||
|
<% if v[12] > 0 %>
|
||||||
|
<tr>
|
||||||
|
<td class="hidden dis p10" style="width:166px;"><%= v[:name] %></td>
|
||||||
|
<td class="w130"><%= v[12] %></td>
|
||||||
|
<td class="w130"><%= v[14] %></td>
|
||||||
|
<td class="w130"><%= v[16] %></td>
|
||||||
|
<td class="w130"><%= v[13] %></td>
|
||||||
|
<td class="w130"><%= v[15] %></td>
|
||||||
|
<td class="w130"><%= v[17] %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<tr>
|
||||||
|
<td class="hidden dis p10" style="width:166px;">Total</td>
|
||||||
|
<td class="w130"><%= @closetotal[0] %></td>
|
||||||
|
<td class="w130"><%= @closetotal[2] %></td>
|
||||||
|
<td class="w130"><%= @closetotal[4] %></td>
|
||||||
|
<td class="w130"><%= @closetotal[1] %></td>
|
||||||
|
<td class="w130"><%= @closetotal[3] %></td>
|
||||||
|
<td class="w130"><%= @closetotal[5] %></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function showResultAll(){
|
||||||
|
$("#result_all").show();
|
||||||
|
$("#result_open").hide();
|
||||||
|
$("#result_close").hide();
|
||||||
|
}
|
||||||
|
function showResultOpen(){
|
||||||
|
$("#result_all").hide();
|
||||||
|
$("#result_open").show();
|
||||||
|
$("#result_close").hide();
|
||||||
|
|
||||||
|
}
|
||||||
|
function showResultClose(){
|
||||||
|
$("#result_all").hide();
|
||||||
|
$("#result_open").hide();
|
||||||
|
$("#result_close").show();
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
|
@ -203,7 +203,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!--缺陷列表开始-->
|
<!--缺陷列表开始-->
|
||||||
<div class="myissues_con ">
|
<div id="myissues_con" class="myissues_con ">
|
||||||
<div class="clear mb5">
|
<div class="clear mb5">
|
||||||
<div class="issues_statistics fl clear">
|
<div class="issues_statistics fl clear">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
$("#myissues_con").html("<%= escape_javascript(render :partial => 'issues/statistics')%>");
|
|
@ -545,6 +545,7 @@ RedmineApp::Application.routes.draw do
|
||||||
get '/projects/:project_id/issues/calendar', :to => 'calendars#show', :as => 'project_calendar'
|
get '/projects/:project_id/issues/calendar', :to => 'calendars#show', :as => 'project_calendar'
|
||||||
get '/issues/calendar', :to => 'calendars#show'
|
get '/issues/calendar', :to => 'calendars#show'
|
||||||
|
|
||||||
|
get 'projects/:id/issues/statistics', :to => 'issues#statistics', :as => 'project_issues_statistics'
|
||||||
get 'projects/:id/issues/report', :to => 'reports#issue_report', :as => 'project_issues_report'
|
get 'projects/:id/issues/report', :to => 'reports#issue_report', :as => 'project_issues_report'
|
||||||
get 'projects/:id/issues/report/:detail', :to => 'reports#issue_report_details', :as => 'project_issues_report_details'
|
get 'projects/:id/issues/report/:detail', :to => 'reports#issue_report_details', :as => 'project_issues_report_details'
|
||||||
post '/users/:id/user_activities', :to => 'users#show', :as => "user_activities"
|
post '/users/:id/user_activities', :to => 'users#show', :as => "user_activities"
|
||||||
|
|
|
@ -2175,3 +2175,27 @@ function autoHeight(id, baseheight) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function getIssueStatistics(url){
|
||||||
|
var tracker_id = $("#tracker_id").attr("value");
|
||||||
|
var subject = $("#v_subject").attr("value");
|
||||||
|
var assigned_to_id = $("#assigned_to_id").attr("value");
|
||||||
|
var fixed_version_id = $("#fixed_version_id").attr("value");
|
||||||
|
var status_id = $("#status_id").attr("value");
|
||||||
|
var done_ratio = $("#done_ratio").attr("value");
|
||||||
|
var test = $("#test").attr("value");
|
||||||
|
var author_id = $("#author_id").attr("value");
|
||||||
|
var priority_id = $("#priority_id").attr("value");
|
||||||
|
var issue_create_date_start = $("#issue_date_start_issue_export").attr("value");
|
||||||
|
var issue_create_date_end = $("#issue_date_end_issue_export").attr("value");
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: url,
|
||||||
|
type: 'get',
|
||||||
|
data: {tracker_id: tracker_id,subject:subject,assigned_to_id:assigned_to_id, fixed_version_id:fixed_version_id, status_id:status_id,done_ratio:done_ratio,test:test,author_id:author_id,priority_id:priority_id,issue_create_date_start:issue_create_date_start,issue_create_date_end:issue_create_date_end},
|
||||||
|
success: function(data){ },
|
||||||
|
beforeSend: function(){ },
|
||||||
|
complete: function(){}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -233,6 +233,7 @@ h4{ font-size:14px;}/*color:#3b3b3b;*/
|
||||||
.w108 {width:108px;}
|
.w108 {width:108px;}
|
||||||
.w125{width:125px;}
|
.w125{width:125px;}
|
||||||
.w128{ width:128px;}
|
.w128{ width:128px;}
|
||||||
|
.w130{ width:130px;}
|
||||||
.w140{ width:140px;}
|
.w140{ width:140px;}
|
||||||
.w150{ width:150px;}
|
.w150{ width:150px;}
|
||||||
.w170{width:170px;}
|
.w170{width:170px;}
|
||||||
|
|
Loading…
Reference in New Issue