优化最近动态获取方法

This commit is contained in:
huang 2016-07-18 13:57:00 +08:00
parent d94f9762ce
commit 412d74e295
2 changed files with 4 additions and 6 deletions

View File

@ -47,13 +47,11 @@ module RepositoriesHelper
end end
# 获取文件目录的最新动态 # 获取文件目录的最新动态
def get_trees_last_changes(project_id, rev, ent_name) def get_trees_last_changes(project_id, rev, ent_name, g)
g = Gitlab.client
begin begin
tree_changes = g.rep_last_changes(project_id, :rev => rev, :path => ent_name) tree_changes = g.rep_last_changes(project_id, :rev => rev, :path => ent_name)
tree_changes rescue Exception => e
rescue puts e
logger.error("faile to get tress activities!")
end end
end end

View File

@ -4,7 +4,7 @@
<% sub_path = entry.path[0] == "/" ? entry.path.sub("/", "") : entry.path %> <% sub_path = entry.path[0] == "/" ? entry.path.sub("/", "") : entry.path %>
<% ent_path = Redmine::CodesetUtil.replace_invalid_utf8(sub_path) %> <% ent_path = Redmine::CodesetUtil.replace_invalid_utf8(sub_path) %>
<% ent_name = Redmine::CodesetUtil.replace_invalid_utf8(entry.name) %> <% ent_name = Redmine::CodesetUtil.replace_invalid_utf8(entry.name) %>
<% latest_changes = get_trees_last_changes(@project.gpid, @rev, ent_path) %> <% latest_changes = get_trees_last_changes(@project.gpid, @rev, ent_path, @g) %>
<tr id="<%= tr_id %>" class="<%= h params[:parent_id] %> entry <%= entry.kind %>"> <tr id="<%= tr_id %>" class="<%= h params[:parent_id] %> entry <%= entry.kind %>">
<td style="padding-left: <%=18 * depth%>px;" class="filename_no_report hidden"> <td style="padding-left: <%=18 * depth%>px;" class="filename_no_report hidden">