From 2c77d1b4cf5df9a214d1ca9b249fd74bfd14dc7a Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 5 Aug 2014 11:10:41 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E8=AE=BF=E9=97=AE=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=BA=93=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 14 +++++++++++++- app/helpers/project_score_helper.rb | 5 +++++ app/models/attachment.rb | 2 +- .../files/_course_show_all_attachment.html.erb | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index a8ba3d426..e619ef843 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -40,7 +40,19 @@ class FilesController < ApplicationController render :layout => !request.xhr? elsif params[:course_id] @isproject = false - @containers = [ Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)] + + if params[:sort] + @oder = params[:sort].split(",")[0] + @order_by = @oder.split(":")[0] + @order_tyoe = @oder.split(":")[1] + if @order_by == "size" + @order_by = "filesize" + end + @containers = [ Course.includes(:attachments).reorder("#{Attachment.table_name}.#{@order_by} #{@order_tyoe}").find(@course.id)] + else + @containers = [ Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)] + end + render :layout => 'base_courses' end end diff --git a/app/helpers/project_score_helper.rb b/app/helpers/project_score_helper.rb index 3df2e05b5..fe7c8307e 100644 --- a/app/helpers/project_score_helper.rb +++ b/app/helpers/project_score_helper.rb @@ -2,7 +2,12 @@ class ProjectScoreHelper #缺陷数量 def issue_num project + project.issues.count + end + #缺陷留言数量 + def issue_journal_num project + project end end \ No newline at end of file diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 85f36fc5f..67e46eb5e 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -193,7 +193,7 @@ class Attachment < ActiveRecord::Base def show_suffix_type suffix = 'other' temp = self.suffix_type.downcase - if self.attachmentstype.suffixArr.include?(temp) + if self.attachmentstype && self.attachmentstype.suffixArr.include?(temp) suffix = temp end suffix diff --git a/app/views/files/_course_show_all_attachment.html.erb b/app/views/files/_course_show_all_attachment.html.erb index f94ddc20b..abece1ae1 100644 --- a/app/views/files/_course_show_all_attachment.html.erb +++ b/app/views/files/_course_show_all_attachment.html.erb @@ -43,7 +43,7 @@ <%= number_to_human_size(file.filesize) %> - <%= file.attachmentstype.typeName %> + <%= file.attachmentstype.typeName unless file.attachmentstype.nil? %> <%= render :partial => 'attachments/course_type_edit', :locals => {:attachmenttypes => attachmenttypes, :attachment => file, :contentype => selContentType} %> From 7907edf168a3b999c24e87775dba49d388cf3e8e Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 5 Aug 2014 16:39:33 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=BE=97=E5=88=86=E8=A7=84=E5=88=99=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=88=97=E8=A1=A8=E6=98=BE=E7=A4=BA=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ReadMe.txt | 5 ++ app/controllers/projects_controller.rb | 1 + app/controllers/welcome_controller.rb | 2 +- app/helpers/project_score_helper.rb | 64 ++++++++++++++++++- app/views/bids/_homework_list.html.erb | 2 +- app/views/layouts/base_projects.html.erb | 29 +-------- .../_code_submit_score_index.html.erb | 7 +- app/views/projects/_file_score_index.html.erb | 7 +- .../projects/_issue_score_index.html.erb | 13 ++-- app/views/projects/_news_score_index.html.erb | 8 +-- app/views/projects/_project.html.erb | 46 +++---------- .../projects/_project_score_index.html.erb | 34 ++-------- .../_projects_topic_score_index.html.erb | 10 +-- .../projects/_show_projects_score.html.erb | 40 ++---------- .../projects/show_projects_score.html.erb | 39 ++--------- app/views/welcome/index.html.erb | 28 +------- .../stylesheets/application.css | 6 +- 17 files changed, 116 insertions(+), 225 deletions(-) diff --git a/ReadMe.txt b/ReadMe.txt index 722b4cd37..b5822682b 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -70,3 +70,8 @@ kw: undefined image_width bundle exec rake db:migrate:down version=20140725062302 bundle exec rake db:migrate:up version=20140725062302 + +=================================[2014-07-19]===================================== +kw: Mysql2::Error,洢,CALL sp_project_status_cursor(); +bundle exec rake db:migrate:down version=20130828004955 +bundle exec rake db:migrate:up version=20130828004955 diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 9b2481c1b..76be5d51f 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -75,6 +75,7 @@ class ProjectsController < ApplicationController helper :watchers # helper :watcherlist helper :words + helper :project_score ### added by william include ActsAsTaggableOn::TagsHelper diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index c7cbf217d..4a0586c95 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -18,7 +18,7 @@ class WelcomeController < ApplicationController include ApplicationHelper include WelcomeHelper - + helper :project_score caches_action :robots # before_filter :fake, :only => [:index, :course] before_filter :entry_select, :only => [:index] diff --git a/app/helpers/project_score_helper.rb b/app/helpers/project_score_helper.rb index fe7c8307e..923a3da72 100644 --- a/app/helpers/project_score_helper.rb +++ b/app/helpers/project_score_helper.rb @@ -1,5 +1,5 @@ # encoding: utf-8 -class ProjectScoreHelper +module ProjectScoreHelper #缺陷数量 def issue_num project project.issues.count @@ -7,7 +7,67 @@ class ProjectScoreHelper #缺陷留言数量 def issue_journal_num project - project + project.issue_changes.count + end + + #新闻数量 + def news_num project + project.news.count + end + + #文档数量 + def document_num project + project.documents.count + end + + #代码提交数量 + def changesets_num project + project.changesets.count + end + + #讨论区帖子数量 + def board_message_num project + board_message_count = 0 + project.boards.each do |board| + board_message_count += board.messages_count + end + board_message_count + end + + #缺陷得分 + def issue_score project + i_num = issue_num project + i_j_num = issue_journal_num project + i_num * 4 + i_j_num + end + + # 新闻得分 + def news_score project + n_num = news_num project + n_num + end + + #文档得分 + def document_score project + d_num = document_num project + d_num * 4 + end + + #代码提交得分 + def changesets_score project + c_num = changesets_num project + c_num * 4 + end + + #讨论区帖子得分 + def board_message_score project + b_m_num = board_message_num project + b_m_num * 2 + end + + #项目得分 + def project_scores project + (issue_score project) + (news_score project) + (document_score project) + (changesets_score project) + (board_message_score project) end end \ No newline at end of file diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 2009d1252..9e8aceaff 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -96,7 +96,7 @@ 项目得分:  ;"> - <%= homework.project.nil? ? "N/A" : project_score(homework.project) %> + <%= homework.project.nil? ? "N/A" : project_scores(homework.project) %> diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index fa20bdff6..b8bede1fb 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -62,37 +62,10 @@ <%= link_to @project.name, project_path(@project)%>
- - <% issue_count = @project.issues.count %> - <% issue_journal_count = @project.issue_changes.count %> - <% issue_score = issue_count * 0.2 %> - <% issue_journal_score = issue_journal_count * 0.1 %> - <% finall_issue_score = issue_score + issue_journal_score %> - - <% new_count = @project.news.count %> - <% new_score = new_count * 0.1 %> - <% finall_new_score = new_score %> - - <% document_count = @project.documents.count %> - <% file_score = document_count * 0.1 %> - <% finall_file_score = file_score %> - - <% changeset_count = @project.changesets.count %> - <% code_submit_score = changeset_count * 0.3 %> - <% finall_code_submit_score = code_submit_score %> - - <% board_message_count = 0 %> - <% @project.boards.each do |board| %> - <% board_message_count += board.messages_count %> - <% end %> - <% topic_score = board_message_count * 0.1 %> - <% finall_topic_score = topic_score %> - - <% finall_project_score = finall_issue_score + finall_new_score + finall_file_score + finall_code_submit_score + topic_score %> <% if @project.project_type == 0 %> <%= l(:label_project_grade)%> : - <%= link_to(format("%.2f" , finall_project_score ).to_f, {:controller => 'projects', + <%= link_to(format("%.2f" , project_scores(@project) ).to_i, {:controller => 'projects', :action => 'show_projects_score', :remote => true, :id => @project.id diff --git a/app/views/projects/_code_submit_score_index.html.erb b/app/views/projects/_code_submit_score_index.html.erb index 238993afe..802779967 100644 --- a/app/views/projects/_code_submit_score_index.html.erb +++ b/app/views/projects/_code_submit_score_index.html.erb @@ -1,7 +1,4 @@ -<% changeset_count = @project.changesets.count %> -<% code_submit_score = changeset_count * 0.3 %> -<% finall_code_submit_score = code_submit_score %> -
<%= l(:label_code_submit_number) %> * 0.3 = <%= changeset_count %> * 0.3 = <%= format("%.2f" , code_submit_score).to_f %>
-
<%= l(:label_code_submit_score) %> = <%= format("%.2f" , finall_code_submit_score).to_f %>
+
<%= l(:label_code_submit_number) %> * 4 = <%= changesets_num(@project) %> * 4 = <%= format("%.2f" , changesets_score(@project)).to_i %>
+
<%= l(:label_code_submit_score) %> = <%= format("%.2f" , changesets_score(@project)).to_i %>
\ No newline at end of file diff --git a/app/views/projects/_file_score_index.html.erb b/app/views/projects/_file_score_index.html.erb index 3b4810f65..ce80ddbd2 100644 --- a/app/views/projects/_file_score_index.html.erb +++ b/app/views/projects/_file_score_index.html.erb @@ -1,7 +1,4 @@ -<% document_count = @project.documents.count %> -<% file_score = document_count * 0.1 %> -<% finall_file_score = file_score %> -
<%= l(:label_file_number) %> * 0.1 = <%= document_count %> * 0.1 = <%= format("%.2f" , file_score).to_f %>
-
<%= l(:label_file_score) %> = <%= format("%.2f" , finall_file_score).to_f %>
+
<%= l(:label_file_number) %> * 4 = <%= document_num(@project) %> * 4 = <%= format("%.2f" , document_score(@project)).to_i %>
+
<%= l(:label_file_score) %> = <%= format("%.2f" , document_score(@project)).to_i %>
\ No newline at end of file diff --git a/app/views/projects/_issue_score_index.html.erb b/app/views/projects/_issue_score_index.html.erb index 8ca3d240c..7353ce5a3 100644 --- a/app/views/projects/_issue_score_index.html.erb +++ b/app/views/projects/_issue_score_index.html.erb @@ -1,11 +1,6 @@ -<% issue_count = @project.issues.count %> -<% issue_journal_count = @project.issue_changes.count %> -<% issue_score = issue_count * 0.2 %> -<% issue_journal_score = issue_journal_count * 0.1 %> -<% finall_issue_score = issue_score + issue_journal_score %> -
<%= l(:label_issue_number) %> * 0.2 = <%= issue_count %> * 0.2 = <%= format("%.2f" , issue_score).to_f %>
-
<%= l(:label_issue_journal_number) %> * 0.1 = <%= issue_journal_count %> * 0.1 = <%= format("%.2f" , issue_journal_score).to_f %>
-
<%= l(:label_issue_score) %> = <%= format("%.2f" , issue_score).to_f %> + <%= format("%.2f" , issue_journal_score).to_f %> - = <%= format("%.2f" , finall_issue_score).to_f %>
+
<%= l(:label_issue_number) %> * 4 = <%= issue_num(@project) %> * 4 = <%= format("%.2f" , issue_num(@project) * 4).to_i %>
+
<%= l(:label_issue_journal_number) %> * 1 = <%= issue_journal_num(@project) %> * 1 = <%= format("%.2f" , issue_journal_num(@project)).to_i %>
+
<%= l(:label_issue_score) %> = <%= format("%.2f" , issue_num(@project) * 4).to_i %> + <%= format("%.2f" , issue_journal_num(@project)).to_i %> + = <%= format("%.2f" , issue_score(@project)).to_i %>
\ No newline at end of file diff --git a/app/views/projects/_news_score_index.html.erb b/app/views/projects/_news_score_index.html.erb index 0f374b871..b3d66efeb 100644 --- a/app/views/projects/_news_score_index.html.erb +++ b/app/views/projects/_news_score_index.html.erb @@ -1,7 +1,5 @@ -<% new_count = @project.news.count %> -<% new_score = new_count * 0.1 %> -<% finall_new_score = new_score %> -
<%= l(:label_new_number) %> * 0.1 = <%= new_count %> * 0.1 = <%= format("%.2f" , new_score).to_f %>
-
<%= l(:label_news_score) %> = <%= format("%.2f" , finall_new_score).to_f %>
+ +
<%= l(:label_new_number) %> * 1 = <%= news_num(@project) %> * 1 = <%= format("%.2f" , news_score(@project)).to_i %>
+
<%= l(:label_news_score) %> = <%= format("%.2f" , news_score(@project)).to_i %>
\ No newline at end of file diff --git a/app/views/projects/_project.html.erb b/app/views/projects/_project.html.erb index 41ad2a62c..e9a733ece 100644 --- a/app/views/projects/_project.html.erb +++ b/app/views/projects/_project.html.erb @@ -18,37 +18,37 @@

- +
- - - - - - - - @@ -124,37 +124,11 @@
- <% issue_count = @project.issues.count %> - <% issue_journal_count = @project.issue_changes.count %> - <% issue_score = issue_count * 0.2 %> - <% issue_journal_score = issue_journal_count * 0.1 %> - <% finall_issue_score = issue_score + issue_journal_score %> - - <% new_count = @project.news.count %> - <% new_score = new_count * 0.1 %> - <% finall_new_score = new_score %> - - <% document_count = @project.documents.count %> - <% file_score = document_count * 0.1 %> - <% finall_file_score = file_score %> - - <% changeset_count = @project.changesets.count %> - <% code_submit_score = changeset_count * 0.3 %> - <% finall_code_submit_score = code_submit_score %> - - <% board_message_count = 0 %> - <% @project.boards.each do |board| %> - <% board_message_count += board.messages_count %> - <% end %> - <% topic_score = board_message_count * 0.1 %> - <% finall_topic_score = topic_score %> - - <% finall_project_score = finall_issue_score + finall_new_score + finall_file_score + finall_code_submit_score + topic_score %> <% if @project.project_type !=1 %> <%= l(:label_project_grade)%>: - <%= link_to(format("%.2f" , finall_project_score ).to_f, + <%= link_to(format("%.2f" , project_scores(@project) ).to_i, {:controller => 'projects', :action => 'show_projects_score', :remote => true, :id => @project.id}, :style=>"color: #EC6300;") %> diff --git a/app/views/projects/_project_score_index.html.erb b/app/views/projects/_project_score_index.html.erb index ab0dc18ca..4a94867fc 100644 --- a/app/views/projects/_project_score_index.html.erb +++ b/app/views/projects/_project_score_index.html.erb @@ -1,36 +1,10 @@ -<% issue_count = @project.issues.count %> -<% issue_journal_count = @project.issue_changes.count %> -<% issue_score = issue_count * 0.2 %> -<% issue_journal_score = issue_journal_count * 0.1 %> -<% finall_issue_score = issue_score + issue_journal_score %> - -<% new_count = @project.news.count %> -<% new_score = new_count * 0.1 %> -<% finall_new_score = new_score %> - -<% document_count = @project.documents.count %> -<% file_score = document_count * 0.1 %> -<% finall_file_score = file_score %> - -<% changeset_count = @project.changesets.count %> -<% code_submit_score = changeset_count * 0.3 %> -<% finall_code_submit_score = code_submit_score %> - -<% board_message_count = 0 %> -<% @project.boards.each do |board| %> -<% board_message_count += board.messages_count %> -<% end %> -<% topic_score = board_message_count * 0.1 %> -<% finall_topic_score = topic_score %> - -<% finall_project_score = finall_issue_score + finall_new_score + finall_file_score + finall_code_submit_score + topic_score %> <%= l(:label_projects_score) %>
= <%= l(:label_issue_score) %> + <%= l(:label_news_score) %> + <%= l(:label_file_score) %> + <%= l(:label_code_submit_score) %> + <%= l(:label_topic_score) %>
-
= <%= format("%.2f" , finall_issue_score).to_f %> + <%= format("%.2f" , finall_new_score).to_f %> + - <%= format("%.2f" , finall_file_score).to_f %> + <%= format("%.2f" , finall_code_submit_score).to_f %> + - <%= format("%.2f" , topic_score).to_f %>
-
= <%= format("%.2f" , finall_project_score).to_f %>
+
= <%= format("%.2f" , issue_score(@project)).to_i %> + <%= format("%.2f" , news_score(@project)).to_i %> + + <%= format("%.2f" , document_score(@project)).to_i %> + <%= format("%.2f" , changesets_score(@project)).to_i %> + + <%= format("%.2f" , board_message_score(@project)).to_i %>
+
= <%= format("%.2f" , project_scores(@project)).to_i %>
\ No newline at end of file diff --git a/app/views/projects/_projects_topic_score_index.html.erb b/app/views/projects/_projects_topic_score_index.html.erb index 1e059007a..909f93a09 100644 --- a/app/views/projects/_projects_topic_score_index.html.erb +++ b/app/views/projects/_projects_topic_score_index.html.erb @@ -1,10 +1,4 @@ -<% board_message_count = 0 %> -<% @project.boards.each do |board| %> -<% board_message_count += board.messages_count %> -<% end %> -<% topic_score = board_message_count * 0.1 %> -<% finall_topic_score = topic_score %> -
<%= l(:label_topic_number) %> * 0.1 = <%= board_message_count %> * 0.1 = <%= topic_score %>
-
<%= l(:label_topic_score) %> = <%= format("%.2f" , finall_topic_score).to_f %>
+
<%= l(:label_topic_number) %> * 2 = <%= board_message_num(@project) %> * 2 = <%= board_message_score(@project) %>
+
<%= l(:label_topic_score) %> = <%= format("%.2f" , board_message_score(@project)).to_i %>
\ No newline at end of file diff --git a/app/views/projects/_show_projects_score.html.erb b/app/views/projects/_show_projects_score.html.erb index d135cfbdb..95c93d520 100644 --- a/app/views/projects/_show_projects_score.html.erb +++ b/app/views/projects/_show_projects_score.html.erb @@ -1,30 +1,4 @@ -<% issue_count = @project.issues.count %> -<% issue_journal_count = @project.issue_changes.count %> -<% issue_score = issue_count * 0.2 %> -<% issue_journal_score = issue_journal_count * 0.1 %> -<% finall_issue_score = issue_score + issue_journal_score %> - -<% new_count = @project.news.count %> -<% new_score = new_count * 0.1 %> -<% finall_new_score = new_score %> - -<% document_count = @project.documents.count %> -<% file_score = document_count * 0.1 %> -<% finall_file_score = file_score %> - -<% changeset_count = @project.changesets.count %> -<% code_submit_score = changeset_count * 0.3 %> -<% finall_code_submit_score = code_submit_score %> - -<% board_message_count = 0 %> -<% @project.boards.each do |board| %> -<% board_message_count += board.messages_count %> -<% end %> -<% topic_score = board_message_count * 0.1 %> -<% finall_topic_score = topic_score %> - -<% finall_project_score = finall_issue_score + finall_new_score + finall_file_score + finall_code_submit_score + topic_score %>

<%= l(:label_projects_score) %>

@@ -40,7 +14,7 @@
@@ -51,27 +25,27 @@
  • <%= link_to l(:label_projects_score), {:controller => 'projects', :action => 'show_projects_score', :remote => true}%> : - <%= format("%.2f" , finall_project_score ).to_f %> + <%= format("%.2f" , project_scores(@project) ).to_i %>
  • <%= link_to l(:label_issue_score), {:controller => 'projects', :action => 'issue_score_index', :remote => true}%> : - <%= format("%.2f" , finall_issue_score).to_f %> + <%= format("%.2f" , issue_score(@project)).to_i %>
  • <%= link_to l(:label_news_score), {:controller => 'projects', :action => 'news_score_index', :remote => true}%> : - <%= format("%.2f" , finall_new_score).to_f %> + <%= format("%.2f" , news_score(@project)).to_i %>
  • <%= link_to l(:label_file_score), {:controller => 'projects', :action => 'file_score_index', :remote => true}%> : - <%= format("%.2f" , finall_file_score).to_f %> + <%= format("%.2f" , document_score(@project)).to_i %>
  • <%= link_to l(:label_code_submit_score), {:controller => 'projects', :action => 'code_submit_score_index', :remote => true}%> : - <%= format("%.2f" , finall_code_submit_score).to_f %> + <%= format("%.2f" , changesets_score(@project)).to_i %>
  • <%= link_to l(:label_topic_score), {:controller => 'projects', :action => 'projects_topic_score_index', :remote => true}%> : - <%= format("%.2f" , finall_topic_score).to_f %> + <%= format("%.2f" , board_message_score(@project)).to_i %>
diff --git a/app/views/projects/show_projects_score.html.erb b/app/views/projects/show_projects_score.html.erb index 95a7085d4..94f3dfaf8 100644 --- a/app/views/projects/show_projects_score.html.erb +++ b/app/views/projects/show_projects_score.html.erb @@ -1,30 +1,5 @@ -<% issue_count = @project.issues.count %> -<% issue_journal_count = @project.issue_changes.count %> -<% issue_score = issue_count * 0.2 %> -<% issue_journal_score = issue_journal_count * 0.1 %> -<% finall_issue_score = issue_score + issue_journal_score %> -<% new_count = @project.news.count %> -<% new_score = new_count * 0.1 %> -<% finall_new_score = new_score %> - -<% document_count = @project.documents.count %> -<% file_score = document_count * 0.1 %> -<% finall_file_score = file_score %> - -<% changeset_count = @project.changesets.count %> -<% code_submit_score = changeset_count * 0.3 %> -<% finall_code_submit_score = code_submit_score %> - -<% board_message_count = 0 %> -<% @project.boards.each do |board| %> - <% board_message_count += board.messages_count %> -<% end %> -<% topic_score = board_message_count * 0.1 %> -<% finall_topic_score = topic_score %> - -<% finall_project_score = finall_issue_score + finall_new_score + finall_file_score + finall_code_submit_score + topic_score %> <%= h html_title %> @@ -56,7 +31,7 @@ @@ -67,27 +42,27 @@
  • <%= link_to l(:label_projects_score), {:controller => 'projects', :action => 'show_projects_score', :remote => true}%> : - <%= format("%.2f" , finall_project_score ).to_f %> + <%= format("%.2f" , project_scores(@project) ).to_i %>
  • <%= link_to l(:label_issue_score), {:controller => 'projects', :action => 'issue_score_index', :remote => true}%> : - <%= format("%.2f" , finall_issue_score).to_f %> + <%= format("%.2f" , issue_score(@project)).to_i %>
  • <%= link_to l(:label_news_score), {:controller => 'projects', :action => 'news_score_index', :remote => true}%> : - <%= format("%.2f" , finall_new_score).to_f %> + <%= format("%.2f" , news_score(@project)).to_i %>
  • <%= link_to l(:label_file_score), {:controller => 'projects', :action => 'file_score_index', :remote => true}%> : - <%= format("%.2f" , finall_file_score).to_f %> + <%= format("%.2f" , document_score(@project)).to_i %>
  • <%= link_to l(:label_code_submit_score), {:controller => 'projects', :action => 'code_submit_score_index', :remote => true}%> : - <%= format("%.2f" , finall_code_submit_score).to_f %> + <%= format("%.2f" , changesets_score(@project)).to_i %>
  • <%= link_to l(:label_topic_score), {:controller => 'projects', :action => 'projects_topic_score_index', :remote => true}%> : - <%= format("%.2f" , finall_topic_score).to_f %> + <%= format("%.2f" , board_message_score(@project)).to_i %>
diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index f8c7f880d..31fb0432a 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -79,33 +79,7 @@ <%=project.description.truncate(100, omission: '...')%>
- <%# issue_count = project.issues.count %> - <%# issue_journal_count = project.issue_changes.count %> - <%# issue_score = issue_count * 0.2 %> - <%# issue_journal_score = issue_journal_count * 0.1 %> - <%# finall_issue_score = issue_score + issue_journal_score %> - - <%# new_count = project.news.count %> - <%# new_score = new_count * 0.1 %> - <%# finall_new_score = new_score %> - - <%# document_count = project.documents.count %> - <%# file_score = document_count * 0.1 %> - <%# finall_file_score = file_score %> - - <%# changeset_count = project.changesets.count %> - <%# code_submit_score = changeset_count * 0.3 %> - <%# finall_code_submit_score = code_submit_score %> - - <%# board_message_count = 0 %> - <%# project.boards.each do |board| %> - <%# board_message_count += board.messages_count %> - <%# end %> - <%# topic_score = board_message_count * 0.1 %> - <%# finall_topic_score = topic_score %> - - <%# finall_project_score = finall_issue_score + finall_new_score + finall_file_score + finall_code_submit_score + topic_score %> - <%= content_tag "span", l(:label_project_score)+ ":" + project_score(project), + <%= content_tag "span", l(:label_project_score)+ ":" + project_scores(project).to_s, :style => "cursor: pointer; display: inline-block; float: right; color: #ec6300;", :title => "项目得分,综合考虑了项目的各项活动,反映了该项目的活跃程度", :class => "tooltip", diff --git a/public/themes/redpenny-master/stylesheets/application.css b/public/themes/redpenny-master/stylesheets/application.css index 0f8113054..9baa5526c 100644 --- a/public/themes/redpenny-master/stylesheets/application.css +++ b/public/themes/redpenny-master/stylesheets/application.css @@ -1070,10 +1070,10 @@ overflow: hidden; .information { margin-top: 20px; - margin-left: 607px; + margin-left: 690px; float: left; height: auto; - width: 300px; + width: 280px; font-family: '微软雅黑',helvetica,arial,sans-serif; /*modify by men*/ color: rgb(0, 0, 0); font-size: 13px; @@ -1232,7 +1232,7 @@ p.stats { .licences { float: left; height: 18px; - width: 260px; + width: 200px; font-size: 13px; font-family: '微软雅黑',helvetica,arial,sans-serif; /*modify by men*/ line-height: 18px; From 1ca64474784f35a4004ad5810c1c093aa21e6eb4 Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 5 Aug 2014 17:31:05 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=BC=BA=E9=99=B7=E3=80=81=E6=96=B0=E9=97=BB=E3=80=81=E8=AE=A8?= =?UTF-8?q?=E8=AE=BA=E5=8C=BA=E7=AD=89=E9=A1=B5=E9=9D=A2=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=9F=A5=E7=9C=8Bbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/boards_controller.rb | 1 + app/controllers/issues_controller.rb | 1 + app/controllers/news_controller.rb | 1 + app/controllers/repositories_controller.rb | 1 + app/views/layouts/base_projects.html.erb | 1 + 5 files changed, 5 insertions(+) diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 40674b53f..72e134fbf 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -26,6 +26,7 @@ class BoardsController < ApplicationController helper :sort include SortHelper helper :watchers + helper :project_score def index #modify by nwb diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index edff1888b..9d734db37 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -52,6 +52,7 @@ class IssuesController < ApplicationController include IssuesHelper helper :timelog include Redmine::Export::PDF + helper :project_score def index retrieve_query diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 650f65555..9437889b2 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -29,6 +29,7 @@ class NewsController < ApplicationController helper :watchers helper :attachments + helper :project_score def index case params[:format] diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 7588eef21..92e897ae3 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -39,6 +39,7 @@ class RepositoriesController < ApplicationController before_filter :check_hidden_repo, :only => [:show, :stats, :revisions, :revision, :diff ] helper :repositories include RepositoriesHelper + helper :project_score #@root_path = RepositoriesHelper::ROOT_PATH diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index b8bede1fb..004aabc51 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -1,3 +1,4 @@ + <% @nav_dispaly_project_label = 1 @nav_dispaly_forum_label = 1 %> <% #@nav_dispaly_project_label = 1 %> From 05186c85903fed4bf56f5b53b3299d656b8c268e Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 6 Aug 2014 11:46:38 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=A7=AF=E5=88=86?= =?UTF-8?q?=E5=AD=98=E6=95=B0=E6=8D=AE=E5=BA=93=20=E6=9C=89=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E7=A7=AF=E5=88=86=E5=BC=95=E8=B5=B7=E7=9A=84=E7=B3=BB?= =?UTF-8?q?=E5=88=97bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/calendars_controller.rb | 1 + app/controllers/documents_controller.rb | 1 + app/controllers/files_controller.rb | 1 + app/controllers/gantts_controller.rb | 1 + app/controllers/issue_categories_controller.rb | 2 ++ app/controllers/messages_controller.rb | 1 + app/controllers/projects_controller.rb | 6 +++--- app/controllers/repositories_controller.rb | 1 + app/controllers/versions_controller.rb | 1 + app/controllers/wiki_controller.rb | 1 + app/helpers/project_score_helper.rb | 15 ++++++++++++++- app/models/project_status.rb | 2 +- 12 files changed, 28 insertions(+), 5 deletions(-) diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb index 2b6797b4f..167fa124a 100644 --- a/app/controllers/calendars_controller.rb +++ b/app/controllers/calendars_controller.rb @@ -27,6 +27,7 @@ class CalendarsController < ApplicationController include QueriesHelper helper :sort include SortHelper + helper :project_score def show if params[:year] and params[:year].to_i > 1900 diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index 2b92c32bb..721ae07ce 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -26,6 +26,7 @@ class DocumentsController < ApplicationController before_filter :authorize_document helper :attachments + helper :project_score def index @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category' diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 9e41f467b..4efa5a85d 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -24,6 +24,7 @@ class FilesController < ApplicationController helper :sort include SortHelper + helper :project_score def index #sort_init 'filename', 'asc' diff --git a/app/controllers/gantts_controller.rb b/app/controllers/gantts_controller.rb index e404ed425..ee132ac29 100644 --- a/app/controllers/gantts_controller.rb +++ b/app/controllers/gantts_controller.rb @@ -29,6 +29,7 @@ class GanttsController < ApplicationController helper :sort include SortHelper include Redmine::Export::PDF + helper :project_score def show @gantt = Redmine::Helpers::Gantt.new(params) diff --git a/app/controllers/issue_categories_controller.rb b/app/controllers/issue_categories_controller.rb index 3bc0ff245..472514cb9 100644 --- a/app/controllers/issue_categories_controller.rb +++ b/app/controllers/issue_categories_controller.rb @@ -26,6 +26,8 @@ class IssueCategoriesController < ApplicationController before_filter :authorize accept_api_auth :index, :show, :create, :update, :destroy + helper :project_score + def index respond_to do |format| format.html { redirect_to_settings_in_projects } diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 451e04d3d..e840664b4 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -28,6 +28,7 @@ class MessagesController < ApplicationController helper :watchers helper :attachments include AttachmentsHelper + helper :project_score REPLIES_PER_PAGE = 25 unless const_defined?(:REPLIES_PER_PAGE) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 76be5d51f..3f6827159 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -494,10 +494,10 @@ class ProjectsController < ApplicationController project_info = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id) user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id) Rails.logger.debug "UserGrade created: #{user_grades.to_json}" - if params[:project][:is_public] == '1' - project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :project_type => @project.project_type) + #if params[:project][:is_public] == '1' + project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :project_type => @project.project_type,:grade => 0) Rails.logger.debug "ProjectStatus created: #{project_status.to_json}" - end + #end @project.members << m @project.project_infos << project_info #end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 92e897ae3..5274bb105 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -207,6 +207,7 @@ class RepositoriesController < ApplicationController flash[:notice] = l(:notice_successful_update) redirect_to settings_project_path(@project, :tab => 'repositories') end + end def destroy diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb index 0bbbd1bd6..3641e0c61 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -29,6 +29,7 @@ class VersionsController < ApplicationController helper :custom_fields helper :projects + helper :project_score def index respond_to do |format| diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 65f58da00..39b3b1753 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -44,6 +44,7 @@ class WikiController < ApplicationController include AttachmentsHelper helper :watchers include Redmine::Export::PDF + helper :project_score # List of pages, sorted alphabetically and by parent (hierarchy) def index diff --git a/app/helpers/project_score_helper.rb b/app/helpers/project_score_helper.rb index 923a3da72..c4c42af24 100644 --- a/app/helpers/project_score_helper.rb +++ b/app/helpers/project_score_helper.rb @@ -67,7 +67,20 @@ module ProjectScoreHelper #项目得分 def project_scores project - (issue_score project) + (news_score project) + (document_score project) + (changesets_score project) + (board_message_score project) + result = (issue_score project) + (news_score project) + (document_score project) + (changesets_score project) + (board_message_score project) + pss = ProjectStatus.where("project_id = '#{project.id}'") + if pss.nil? || pss.count == 0 + ps = ProjectStatus.new + ps.grade = result + ps.project = project + ps.watchers_count = project.watcher_users.count + ps.save + else + ps = pss.first + ps.grade = result + ps.save + end + result end end \ No newline at end of file diff --git a/app/models/project_status.rb b/app/models/project_status.rb index 09200e36a..c3d306c58 100644 --- a/app/models/project_status.rb +++ b/app/models/project_status.rb @@ -1,5 +1,5 @@ class ProjectStatus < ActiveRecord::Base - attr_accessible :changesets_count, :watchers_count, :project_id, :project_type + attr_accessible :changesets_count, :watchers_count, :project_id, :project_type,:grade belongs_to :project belongs_to :watchers belongs_to :changesets From 0eca547ec55c87c1a2c02f3f1f4de2cc06035b5e Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 6 Aug 2014 15:03:43 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=A4=E4=B8=AA?= =?UTF-8?q?=E5=AF=BC=E8=88=AA=E6=A0=8F=E4=B8=A2=E5=A4=B1=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=81=E7=89=88=E6=9C=AC=E5=BA=93=3D=E3=80=8B=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=E5=B7=AE=E5=88=AB=EF=BC=8C=E6=B2=A1=E6=9C=89=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E7=9A=84=E6=96=87=E4=BB=B6=E6=88=96=E4=BF=AE=E8=AE=A2?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=97=B6=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 12 +++++++++++- lib/tasks/project_score.rake | 0 .../app/controllers/code_review_controller.rb | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 lib/tasks/project_score.rake diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 5274bb105..ef4c9b061 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -206,8 +206,15 @@ class RepositoriesController < ApplicationController @repository.committer_ids = params[:committers].values.inject({}) {|h, c| h[c.first] = c.last; h} flash[:notice] = l(:notice_successful_update) redirect_to settings_project_path(@project, :tab => 'repositories') + elsif request.get? + respond_to do |format| + format.html{ + render :layout => "project_base" + } end + + end end def destroy @@ -414,7 +421,10 @@ class RepositoriesController < ApplicationController Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}-#{current_language}") unless read_fragment(@cache_key) @diff = @repository.diff(@path, @rev, @rev_to) - show_error_not_found unless @diff + unless @diff + show_error_not_found + return + end end @changeset = @repository.find_changeset_by_name(@rev) diff --git a/lib/tasks/project_score.rake b/lib/tasks/project_score.rake new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/redmine_code_review/app/controllers/code_review_controller.rb b/plugins/redmine_code_review/app/controllers/code_review_controller.rb index 33f5a203a..83a2602fd 100644 --- a/plugins/redmine_code_review/app/controllers/code_review_controller.rb +++ b/plugins/redmine_code_review/app/controllers/code_review_controller.rb @@ -16,6 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class CodeReviewController < ApplicationController + layout "project_base" unloadable before_filter :find_project, :authorize, :find_user, :find_setting, :find_repository From c6271e2aa9d9731dd6fef8b2fdc689c0c6271ffe Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 6 Aug 2014 16:02:26 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=B1=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E7=A7=AF=E5=88=86=E6=94=B9=E5=8A=A8=E5=BC=95=E8=B5=B7?= =?UTF-8?q?=E7=9A=84=E4=B8=80=E4=B8=AA=E9=A1=B5=E9=9D=A2=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=9F=A5=E7=9C=8Bbug=E3=80=81=E6=B7=BB=E5=8A=A0=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=BE=97=E5=88=86=E7=BB=9F=E8=AE=A1=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/activities_controller.rb | 2 +- app/helpers/project_score_helper.rb | 1 + lib/tasks/project_score.rake | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/controllers/activities_controller.rb b/app/controllers/activities_controller.rb index e1ec7a799..9611a9621 100644 --- a/app/controllers/activities_controller.rb +++ b/app/controllers/activities_controller.rb @@ -20,7 +20,7 @@ class ActivitiesController < ApplicationController before_filter :find_optional_project, :index accept_rss_auth :index helper :Watchers - + helper :project_score def index @days = Setting.activity_days_default.to_i diff --git a/app/helpers/project_score_helper.rb b/app/helpers/project_score_helper.rb index c4c42af24..0e8c0de9b 100644 --- a/app/helpers/project_score_helper.rb +++ b/app/helpers/project_score_helper.rb @@ -74,6 +74,7 @@ module ProjectScoreHelper ps.grade = result ps.project = project ps.watchers_count = project.watcher_users.count + ps.changesets_count = project.changesets.count ps.save else ps = pss.first diff --git a/lib/tasks/project_score.rake b/lib/tasks/project_score.rake index e69de29bb..5a1f7955f 100644 --- a/lib/tasks/project_score.rake +++ b/lib/tasks/project_score.rake @@ -0,0 +1,17 @@ +# -*coding:utf-8 -*- +desc "project score Initialize" +task :project_score do + puts "project_score sync." +end + +namespace :project_score do + desc "calculating first page" + task :calculate => :environment do + include ProjectScoreHelper + Project.where("project_type != 1").all.each do |project| + result = project_scores(project) + puts "score of #{project.name} is #{result}" + end + puts "calculate completed" + end +end \ No newline at end of file From 17e6f0ee4f45e057909072f5ee2cb9f5b6db822b Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 7 Aug 2014 08:51:19 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E9=83=A8=E5=88=86=E7=A7=81=E6=9C=89?= =?UTF-8?q?=E7=9A=84=E9=A1=B9=E7=9B=AE=E6=8F=90=E4=BA=A4=E6=AC=A1=E6=95=B0?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/project_score_helper.rb | 3 +++ app/helpers/user_score_helper.rb | 41 ++++++++++++++++++----------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/app/helpers/project_score_helper.rb b/app/helpers/project_score_helper.rb index 0e8c0de9b..6cf7e7767 100644 --- a/app/helpers/project_score_helper.rb +++ b/app/helpers/project_score_helper.rb @@ -79,6 +79,9 @@ module ProjectScoreHelper else ps = pss.first ps.grade = result + if ps.changesets_count.nil? || ps.changesets_count == "" + ps.changesets_count = project.changesets.count + end ps.save end result diff --git a/app/helpers/user_score_helper.rb b/app/helpers/user_score_helper.rb index de7b2d6ec..5f47afb5a 100644 --- a/app/helpers/user_score_helper.rb +++ b/app/helpers/user_score_helper.rb @@ -337,12 +337,15 @@ module UserScoreHelper :activity => activity, :file => file, :issue => issue, :level => level) end - #==================================================================================================== - def get_option_number(user,type,project_id=nil) - if project_id.nil? + #======================================================================================================== + #个人得分统计 + #======================================================================================================== + #type 1:个人得分、2:个人在项目project中的得分 + def get_option_number(user,type,project=nil) + if project.nil? option_number = OptionNumber.where("user_id = '#{user.id}' and score_type = '#{type}'"); else - option_number = OptionNumber.where("user_id = '#{user.id}' and score_type = '#{type}' and project_id = '#{project_id}'"); + option_number = OptionNumber.where("user_id = '#{user.id}' and score_type = '#{type}' and project_id = '#{project.id}'"); end result = nil @@ -402,9 +405,9 @@ module UserScoreHelper end #更新发帖数 - def update_memo_number(user,type) - option_number = get_option_number(user,type) - option_number.memo = Message.includes(:author).where("parent_id IS NULL and author_id = '#{user.id}'").all.count + Memo.includes(:author).where("parent_id IS NULL and author_id = '#{user.id}'").all.count + def update_memo_number(user,type,project=nil) + option_number = get_option_number(user,type,project) + option_number.memo = memo_num(user,project)#Message.includes(:author).where("parent_id IS NULL and author_id = '#{user.id}'").all.count + Memo.includes(:author).where("parent_id IS NULL and author_id = '#{user.id}'").all.count update_score(option_number) end @@ -419,9 +422,9 @@ module UserScoreHelper end #更新对缺陷留言数 - def update_messges_for_issue(user,type) + def update_messges_for_issue(user,type,project=nil) option_number = get_option_number(user,type) - option_number.messages_for_issues = Journal.includes(:user).where("user_id = '#{user.id}' and notes != '' and notes is not null").all.count + option_number.messages_for_issues = messges_for_issue_num(user,project)#Journal.includes(:user).where("user_id = '#{user.id}' and notes != '' and notes is not null").all.count update_score(option_number) end @@ -434,9 +437,9 @@ module UserScoreHelper end #更新更改缺陷状态状态次数 - def update_issues_status(user,type) + def update_issues_status(user,type,project=nil) option_number = get_option_number(user,type) - option_number.issues_status = Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count + option_number.issues_status = issues_status_num(user,project)#Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count update_score(option_number) end @@ -450,14 +453,19 @@ module UserScoreHelper end #更新对留言的回复数量 - def update_replay_for_message(user,type) + def update_replay_for_message(user,type,project=nil) option_number = get_option_number(user,type) - option_number.replay_for_message = JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id}").count + option_number.replay_for_message = replay_for_message_num(user,project)#JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id}").count update_score(option_number) end - - def replay_for_message_num(user) + #====================================contiue here===================================================== + def replay_for_message_num(user,project=nil) + if project.nil? JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id}").count + else + + end + end #更新对帖子的回复数量 @@ -727,6 +735,9 @@ module UserScoreHelper else Issue.includes(:author).where("author_id = '#{user.id}' and project_id = '#{project.id}'").all.count end + end + + def user_scores(user,type) end end
+ <%= link_to @project.watcher_users.count, project_watcherlist_path(project)%> + <%= content_tag('span', l(:label_x_follow_people,:count =>@project.watcher_users.count)) %>
+ <%= link_to "#{@project.members.count}", project_member_path(@project)%> + <%= content_tag('span', l(:label_x_current_contributors, :count => @project.users.count)) %>
+ <%= content_tag('span', "#{(@project.repository.nil? || @project.repository.changesets[0].nil?) ? '0' : distance_of_time_in_words(Time.now, @project.repository.changesets[0].committed_on)}", :class => "info") %> + <%= content_tag('span', l(:label_since_last_commits)) %>
+ <% #find_project_repository @project %> <%= content_tag('span', "#{@project.repository.nil? || @project.project_status.nil? ? '0' : @project.project_status.changesets_count }", :class => "info") %> + <%= content_tag('span', l(:label_commit_on)) %>
- +
<%= l(:label_projects_score) %>
<%= format("%.2f" , finall_project_score ).to_f %>
<%= format("%.2f" , project_scores(@project) ).to_i %>
- +
<%= l(:label_projects_score) %>
<%= format("%.2f" , finall_project_score ).to_f %>
<%= format("%.2f" , project_scores(@project) ).to_i %>