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