issue编辑优化,性能简单优化

This commit is contained in:
huang 2016-12-08 09:55:41 +08:00
parent 122946804d
commit a1a96e4667
5 changed files with 21 additions and 3 deletions

View File

@ -320,6 +320,9 @@ class IssuesController < ApplicationController
def edit def edit
# 修改实例变量的值 # 修改实例变量的值
return unless update_issue_from_params return unless update_issue_from_params
# issue 关联的commit
commit_issues = CommitIssues.where(:issue_id => @issue.id, :project_id => @issue.project_id)
@issue_commit_ids = commit_issues.map{|commit_issue| commit_issue.commit_id}
respond_to do |format| respond_to do |format|
format.html {render :layout => 'base_projects' }#added by young format.html {render :layout => 'base_projects' }#added by young

View File

@ -27,6 +27,21 @@ module RepositoriesHelper
REPO_IP_ADDRESS = Setting.host_repository REPO_IP_ADDRESS = Setting.host_repository
REPO_GITLAB_ADDRESS = "git.trustie.net" REPO_GITLAB_ADDRESS = "git.trustie.net"
# 获取某次提交的关联Issue
# REDO:一次关联查询
# type为true则为详情页面全部显示
def get_commit_issues commit_id, project_id, type
commit_issues = CommitIssues.where(:commit_id => commit_id, :project_id => project_id)
unless commit_issues.blank?
if commit_issues.count > 2 && type != 1
result = commit_issues.map{|commit_issue| commit_issue.issue_id}.first(2) << "more"
else
result = commit_issues.map{|commit_issue| commit_issue.issue_id}
end
end
return result unless result.blank?
end
# 因为gitlab的提交总数不是实时同步的说以取总数用两种方法 # 因为gitlab的提交总数不是实时同步的说以取总数用两种方法
def choise_commit_count git_count, pro_count def choise_commit_count git_count, pro_count
git_count > pro_count ? git_count : pro_count git_count > pro_count ? git_count : pro_count

View File

@ -175,7 +175,7 @@
} }
$.ajax({ $.ajax({
url: '<%= url_for(:controller => 'issues', :action => 'issue_commits') %>', url: '<%= url_for(:controller => 'issues', :action => 'issue_commits') %>',
type:'post', type:'get',
data:{ data:{
project_id: project_id, project_id: project_id,
issue_commit_ids: str issue_commit_ids: str

View File

@ -17,7 +17,7 @@
<%= link_to commit.id[0,8], {:controller => 'repositories', :action => 'commit_diff', :id => @project.id, :changeset => commit.id}, :target => "_blank" %></span> <%= link_to commit.id[0,8], {:controller => 'repositories', :action => 'commit_diff', :id => @project.id, :changeset => commit.id}, :target => "_blank" %></span>
</td> </td>
<td class="newupload_td02"><p><%= commit.title %></p></td> <td class="newupload_td02"><p><%= commit.title %></p></td>
<td class="newupload_td04"><span class="newupload_table_name"><%= link_to_user_mail(commit.author_email) %></span></td> <td class="newupload_td04"><span class="newupload_table_name"><%= link_to_user_mail(commit.author_email, "") %></span></td>
<td class="newupload_td05"><%= format_date(commit.created_at) %></td> <td class="newupload_td05"><%= format_date(commit.created_at) %></td>
</tr> </tr>
<% end %> <% end %>

View File

@ -952,7 +952,7 @@ RedmineApp::Application.routes.draw do
collection do collection do
match 'bulk_edit', :via => [:get, :post] match 'bulk_edit', :via => [:get, :post]
post 'bulk_update' post 'bulk_update'
post 'issue_commits' get 'issue_commits'
get 'commit_for_issue' get 'commit_for_issue'
get 'issue_commit_delete' get 'issue_commit_delete'
end end