diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9572034aa..03bbcad3c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -123,7 +123,7 @@ module ApplicationHelper CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :homework_journal_num => 1) else score = course_contributor_score.homework_journal_num.to_i + 1 - course_contributor_score.update_attributes(:homework_journal_num => score) + course_contributor_score.update_column(:homework_journal_num, score) end # 课程留言 when "Course" @@ -131,42 +131,42 @@ module ApplicationHelper CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :journal_num => 1) else score = course_contributor_score.journal_num.to_i + 1 - course_contributor_score.update_attributes(:journal_num => score) + course_contributor_score.update_column(:journal_num, score) end when "Message" if course_contributor_score.nil? CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 1) else score = course_contributor_score.message_num.to_i + 1 - course_contributor_score.update_attributes(:message_num => score) + course_contributor_score.update_column(:message_num, score) end when "MessageReply" if course_contributor_score.nil? CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_reply_num => 1) else score = course_contributor_score.message_reply_num.to_i + 1 - course_contributor_score.update_attributes(:message_reply_num => score) + course_contributor_score.update_column(:message_reply_num, score) end when "NewReply" if course_contributor_score.nil? CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :news_reply_num => 1) else score = course_contributor_score.news_reply_num.to_i + 1 - course_contributor_score.update_attributes(:news_reply_num => score) + course_contributor_score.update_column(:news_reply_num, score) end when "News" if course_contributor_score.nil? CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :news_num => 1) else score = course_contributor_score.news_num.to_i + 1 - course_contributor_score.update_attributes(:news_num => score) + course_contributor_score.update_column(:news_num, score) end when "Attachment" if course_contributor_score.nil? CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :resource_num => 1) else score = course_contributor_score.resource_num.to_i + 1 - course_contributor_score.update_attributes(:resource_num => score) + course_contributor_score.update_column(:resource_num, score) end end end @@ -178,38 +178,38 @@ module ApplicationHelper when "HomeworkCommon" unless course_contributor_score.nil? score = course_contributor_score.homework_journal_num.to_i - 1 - course_contributor_score.update_attribute(:homework_journal_num, score < 0 ? 0 : score) + course_contributor_score.update_column(:homework_journal_num, score < 0 ? 0 : score) end # 课程留言 when "Course" unless course_contributor_score.nil? score = course_contributor_score.journal_num.to_i - 1 - course_contributor_score.update_attribute(:journal_num, score < 0 ? 0 : score) + course_contributor_score.update_column(:journal_num, score < 0 ? 0 : score) end when "Message" unless course_contributor_score.nil? score = course_contributor_score.message_num.to_i - 1 - course_contributor_score.update_attribute(:message_num, score < 0 ? 0 : score) + course_contributor_score.update_column(:message_num, score < 0 ? 0 : score) end when "MessageReply" unless course_contributor_score.nil? score = course_contributor_score.message_reply_num.to_i - 1 - course_contributor_score.update_attribute(:message_reply_num, score < 0 ? 0 : score) + course_contributor_score.update_column(:message_reply_num, score < 0 ? 0 : score) end when "NewReply" unless course_contributor_score.nil? score = course_contributor_score.news_reply_num.to_i - 1 - course_contributor_score.update_attribute(:news_reply_num, score < 0 ? 0 : score) + course_contributor_score.update_column(:news_reply_num, score < 0 ? 0 : score) end when "News" unless course_contributor_score.nil? score = course_contributor_score.news_num.to_i - 1 - course_contributor_score.update_attribute(:news_num, score < 0 ? 0 : score) + course_contributor_score.update_column(:news_num, score < 0 ? 0 : score) end when "Attachment" unless course_contributor_score.nil? score = course_contributor_score.resource_num.to_i - 1 - course_contributor_score.update_attribute(:resource_num, score < 0 ? 0 : score) + course_contributor_score.update_column(:resource_num, score < 0 ? 0 : score) end end end diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 36187b460..688fd1505 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -41,6 +41,17 @@ module RepositoriesHelper identifiers.include?(iden) ? false :true end + # 获取文件目录的最新动态 + def get_trees_last_changes(project_id, rev) + g = Gitlab.client + begin + tree_changes = g.rep_last_changes(project_id, :rev => rev) + tree_changes + rescue + logger.error("faile to get tress activities!") + end + end + # 获取diff内容行号 def diff_line_num content content.scan(/@@ -(\d+),\d+ \+\d+,\d+ @@/).first.join("").to_i diff --git a/app/views/repositories/_dir_list_content.html.erb b/app/views/repositories/_dir_list_content.html.erb index dda0cddbd..e82f10689 100644 --- a/app/views/repositories/_dir_list_content.html.erb +++ b/app/views/repositories/_dir_list_content.html.erb @@ -3,6 +3,8 @@ depth = params[:depth].to_i %> <% ent_path = Redmine::CodesetUtil.replace_invalid_utf8(entry.path) %> <% ent_name = Redmine::CodesetUtil.replace_invalid_utf8(entry.name) %> +<% get_trees_last_changes(@project.id, @rev) %> + "> @@ -23,11 +25,11 @@ -<% if @repository.report_last_commit %> - <%= link_to_revision(entry.changeset, @repository) if entry.changeset %> - <%= distance_of_time_in_words(entry.lastrev.time, Time.now) if entry.lastrev && entry.lastrev.time %> - <%= entry.author %> - <%=h truncate(entry.changeset.comments, :length => 50) if entry.changeset %> -<% end %> +<%# if @repository.report_last_commit %> + + 一个月前<%#= distance_of_time_in_words(entry.lastrev.time, Time.now) if entry.lastrev && entry.lastrev.time %> + huang<%#= entry.author %> + 修改版本库<%#=h truncate(entry.changeset.comments, :length => 50) if entry.changeset %> +<%# end %> <% end %> diff --git a/lib/gitlab-cli/lib/gitlab/client/repositories.rb b/lib/gitlab-cli/lib/gitlab/client/repositories.rb index 98a8ea150..990300b31 100644 --- a/lib/gitlab-cli/lib/gitlab/client/repositories.rb +++ b/lib/gitlab-cli/lib/gitlab/client/repositories.rb @@ -106,6 +106,23 @@ class Gitlab::Client end alias_method :repo_rep_stats, :rep_stats + # Gets a tree activities of project repository. + # + # @example + # Gitlab.commits('viking') + # Gitlab.repo_commits('gitlab', :ref_name => 'api') + # + # @param [Integer] project The ID of a project. + # @param [Hash] options A customizable set of options. + # @option options [String] :ref_name The branch or tag name of a project repository. + # @option options [String] :creator The user name of a project repository. + # @option options [Integer] :period Statistics over time. 1:total 2:one month 3:one week + # @return [Array] + def rep_last_changes(project, options={}) + get("/projects/#{project}/repository/rep_last_changes", :query => options) + end + alias_method :repo_rep_stats, :rep_stats + # Get the diff of a commit in a project. # # @example diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css index 085fc64be..a1d372e11 100644 --- a/public/stylesheets/project.css +++ b/public/stylesheets/project.css @@ -593,6 +593,9 @@ img.ui-datepicker-trigger { .repos_files ul:hover{ background:#ffffdd;} .repos_t_c li{ text-align:center;} .pic_stats{display:block; background:url(../images/public_icon.png) 0px -548px no-repeat; width:20px; height:15px;} +.tree-age{width:10%; text-align:right;} +.tree-author{width:10%; text-align:right;} +.tree-comments{width:20%; text-align:right;} /* 里程碑 */ @@ -816,7 +819,7 @@ div.changeset { border-bottom: 1px solid #ddd; } tr.entry { border: 1px solid #DDD; } tr.entry td { white-space: nowrap; } tr.entry td.filename { width: 30%; } -tr.entry td.filename_no_report { width: 70%; } +tr.entry td.filename_no_report { width: 60%; } tr.entry td.size { text-align: right; font-size: 90%; } tr.entry td.revision, tr.entry td.author { text-align: center; } tr.entry td.age { text-align: right; }