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/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/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 49ee47327..be27a71ea 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -29,6 +29,7 @@ class BidsController < ApplicationController helper :projects helper :words helper :welcome + helper :project_score def find_project_by_bid_id @bid = Bid.find(params[:id]) 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/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/courses_controller.rb b/app/controllers/courses_controller.rb index 85dfba8cf..6989b0b4f 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -624,7 +624,9 @@ class CoursesController < ApplicationController "show_course_journals_for_messages" => true } @date_to ||= Date.today + 1 - @date_from = @date_to - @days-1.years + # + @date_from = (@date_to - @days) > @course.created_at.to_date ? (@date_to - @days) : @course.created_at.to_date + #@date_from = @date_to - @days-1.years @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id])) # 决定显示所用用户或单个用户活动 @activity = Redmine::Activity::Fetcher.new(User.current, :course => @course, 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 a8ba3d426..c80ce6d69 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' @@ -40,7 +41,32 @@ 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] + if params[:sort].include?":" + @orderBy = params[:sort].split(":")[0] + @orderType = params[:sort].split(":")[1].split(",")[0] + else + @orderBy = params[:sort].split(",")[0] + @orderType = "asc" + end + end + + if @orderBy=="size" + @orderBy="filesize" + elsif @orderBy=="field_file_dense" + @orderBy="is_public" + elsif @orderBy=="attach_type" + @orderBy="attachtype" + elsif @orderBy=="content_type" + @orderBy="attachtype" + end + + if @orderBy + @containers = [ Course.includes(:attachments).reorder("#{Attachment.table_name}.#{@orderBy} #{@orderType}").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/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/git_usage_controller.rb b/app/controllers/git_usage_controller.rb index 69b0c7f55..4f9a96d6f 100644 --- a/app/controllers/git_usage_controller.rb +++ b/app/controllers/git_usage_controller.rb @@ -1,5 +1,6 @@ #added by baiyu class GitUsageController < ApplicationController + layout "project_base" def ch_usage end 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/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/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/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/notificationcomments_controller.rb b/app/controllers/notificationcomments_controller.rb index 80500ab10..43cad6cbb 100644 --- a/app/controllers/notificationcomments_controller.rb +++ b/app/controllers/notificationcomments_controller.rb @@ -1,4 +1,7 @@ class NotificationcommentsController < ApplicationController + def show + + end # default_search_scope :contestnotifications # model_object Contestnotifications # before_filter :authorize @@ -20,8 +23,14 @@ class NotificationcommentsController < ApplicationController end def destroy - @contestnotifications.notificaioncomments.find(params[:notificaioncomment_id]).destroy - redirect_to contest_contestnotification_path(@contestnotifications) + @contest = Contest.find(params[:contest_id]) + @contestnotification = Contestnotification.find(params[:contestnotification_id]) + notificaioncomments = Notificationcomment.find(params[:id]) + notificaioncomments.destroy if notificaioncomments + #@contestnotifications = notificaioncomments.Contestnotification + #@contest = @contestnotifications.contest + #@contestnotifications.notificaioncomments.find(params[:notificaioncomment_id]).destroy + redirect_to contest_contestnotification_path(@contest,@contestnotification) end end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 9b2481c1b..3f6827159 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 @@ -493,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 7588eef21..ef4c9b061 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 @@ -205,6 +206,14 @@ 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 @@ -412,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/app/controllers/softapplications_controller.rb b/app/controllers/softapplications_controller.rb index f2b0a0c83..067465b40 100644 --- a/app/controllers/softapplications_controller.rb +++ b/app/controllers/softapplications_controller.rb @@ -156,8 +156,8 @@ class SoftapplicationsController < ApplicationController format.html { redirect_to show_attendingcontest_contest_path(:id => params[:contest_id]), notice: l(:notice_attendingcontest_work_successfully_created) } # format.json { render json: @softapplication, status: :created, location: @softapplication } else - format.js { render status: 406 } - format.html { render action: "new" } + #format.js { render status: 406 } + format.html { render action: "contests/show_attendingcontest" } # format.json { render json: @softapplication.errors, status: :unprocessable_entity } end end 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/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/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/members_helper.rb b/app/helpers/members_helper.rb index 134b7c007..ecfb097e9 100644 --- a/app/helpers/members_helper.rb +++ b/app/helpers/members_helper.rb @@ -53,10 +53,13 @@ module MembersHelper # 当前申请加入的成员名单 def render_principals_for_applied_members(project) - scope = Principal.active.sorted.applied_members(project).like(params[:q]) + scope = project.applied_projects.map(&:user) principal_count = scope.count principal_pages = Redmine::Pagination::Paginator.new principal_count, 10, params['page'] - principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all + offset ||= principal_pages.offset + principals = scope[offset, 10] + #principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all + #principals = ApplicationController.new.paginateHelper scope,10 s = content_tag('div', principals_check_box_tags_ex('membership[user_ids][]', principals), :id => 'principals') diff --git a/app/helpers/project_score_helper.rb b/app/helpers/project_score_helper.rb index 3df2e05b5..6cf7e7767 100644 --- a/app/helpers/project_score_helper.rb +++ b/app/helpers/project_score_helper.rb @@ -1,8 +1,90 @@ # encoding: utf-8 -class ProjectScoreHelper +module ProjectScoreHelper #缺陷数量 def issue_num project + project.issues.count + end + + #缺陷留言数量 + def issue_journal_num 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 + 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.changesets_count = project.changesets.count + ps.save + 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 end end \ No newline at end of file diff --git a/app/helpers/user_score_helper.rb b/app/helpers/user_score_helper.rb index de7b2d6ec..8c00a6b23 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 @@ -382,6 +385,7 @@ module UserScoreHelper def update_score(option_number) option_number.total_score = collaboration(option_number) + influence(option_number) + skill(option_number) + active(option_number) option_number.save + option_number.total_score end #协同得分 @@ -402,16 +406,16 @@ 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 #发帖数 def memo_num(user,project=nil) if project.nil? - Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id != -1").all.count + Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id != -1").all.count #+ Memo.includes(:author).where("parent_id IS NULL and author_id = '#{user.id}'").all.count else Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id = #{project.id}").all.count end @@ -419,9 +423,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 +438,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,26 +454,31 @@ 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) - JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id}").count + 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} and jour_type = 'Project'").count + else + JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id} and jour_type = 'Project' and jour_id = '#{project.id}'").count + end + end #更新对帖子的回复数量 - def update_replay_for_memo(user,type) + def update_replay_for_memo(user,type,project=nil) option_number = get_option_number(user,type) - option_number.replay_for_memo = Message.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count #+ Memo.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count + option_number.replay_for_memo = replay_for_memo_num(user,project)#Message.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count #+ Memo.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count update_score(option_number) end def replay_for_memo_num(user,project=nil) if project.nil? - Message.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count + Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NOT NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id != -1").all.count else Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NOT NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id = #{project.id}").all.count end @@ -487,32 +496,13 @@ module UserScoreHelper end #更新帖子踩各项数量 - def update_tread(user,type) + def update_tread(user,type,project=nil) option_number = get_option_number(user,type) - option_number.tread = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 0 and user_id = '#{user.id}'").all.count - pts = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 0").all - result = [] - result1 = [] - result2 = [] - pts.each do |pt| - obj = PraiseTread.find_object_by_type_and_id(pt.praise_tread_object_type, pt.praise_tread_object_id) - if obj.nil? - next - end - target_user = obj.author - level = UserLevels.get_level(pt.user)#pt.user.get_level - project = pt.project - if level == 1 && target_user.id = user.id - result << pt - elsif level == 2 && target_user.id = user.id - result1 << pt - elsif level == 3 && target_user.id = user.id - result2 << pt - end - end - option_number.tread_by_one = result.count - option_number.tread_by_two = result1.count - option_number.tread_by_three = result2.count + tread_nums = tread_num(user,project) + option_number.tread = tread_nums[:tread] + option_number.tread_by_one = tread_nums[:tead_by_one] + option_number.tread_by_two = tread_nums[:tread_by_two] + option_number.tread_by_three = tread_nums[:tread_by_three] update_score(option_number) end @@ -571,31 +561,12 @@ module UserScoreHelper end #更新帖子顶数量 - def update_praise(user,type) + def update_praise(user,type,project=nil) option_number = get_option_number(user,type) - pts = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 1").all - result = [] - result1 = [] - result2 = [] - pts.each do |pt| - obj = PraiseTread.find_object_by_type_and_id(pt.praise_tread_object_type, pt.praise_tread_object_id) - if obj.nil? - next - end - target_user = obj.author - level = UserLevels.get_level(pt.user)#pt.user.get_level - project = pt.project - if level == 1 && target_user.id = user.id - result << pt - elsif level == 2 && target_user.id = user.id - result1 << pt - elsif level == 3 && target_user.id = user.id - result2 << pt - end - end - option_number.praise_by_one = result.count - option_number.praise_by_two = result1.count - option_number.praise_by_three = result2.count + praise_nums = praise_num(user,project) + option_number.praise_by_one = praise_nums[:praise_by_one] + option_number.praise_by_two = praise_nums[:praise_by_two] + option_number.praise_by_three = praise_nums[:praise_by_three] update_score(option_number) end @@ -635,6 +606,9 @@ module UserScoreHelper if obj.nil? next end + #if obj.project.id == -1 + # next + #end target_user = obj.author level = UserLevels.get_level(pt.user)#pt.user.get_level project = pt.project @@ -652,9 +626,9 @@ module UserScoreHelper end #更新提交代码次数 - def update_changeset(user,type) + def update_changeset(user,type,project=nil) option_number = get_option_number(user,type) - option_number.changeset = Changeset.includes(:user).where("user_id = '#{user.id}'").all.count + option_number.changeset = changeset_num(user,project)#Changeset.includes(:user).where("user_id = '#{user.id}'").all.count update_score(option_number) end @@ -668,9 +642,9 @@ module UserScoreHelper end #更新文档提交次数 - def update_document(user,type) + def update_document(user,type,project=nil) option_number = get_option_number(user,type) - option_number.document = Document.includes(:user).where("user_id = '#{user.id}'").all.count + option_number.document = document_num(user,project)#Document.includes(:user).where("user_id = '#{user.id}'").all.count update_score(option_number) end @@ -684,9 +658,9 @@ module UserScoreHelper end #更新附件提交数量 - def update_attachment(user,type) + def update_attachment(user,type,project=nil) option_number = get_option_number(user,type) - option_number.attachment = Attachment.includes(:author).where("author_id = '#{user.id}'").all.count + option_number.attachment = attachment_num(user,project)#Attachment.includes(:author).where("author_id = '#{user.id}'").all.count update_score(option_number) end @@ -699,9 +673,9 @@ module UserScoreHelper end #更新缺陷完成度次数 - def update_issue_done_ratio(user,type) + def update_issue_done_ratio(user,type,project=nil) option_number = get_option_number(user,type) - option_number.issue_done_ratio = Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'done_ratio' and #{User.table_name}.id = '#{user.id}'").count + option_number.issue_done_ratio = issue_done_ratio_num(user,project) #Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'done_ratio' and #{User.table_name}.id = '#{user.id}'").count update_score(option_number) end @@ -715,9 +689,9 @@ module UserScoreHelper end #更新发布缺陷次数 - def update_post_issue(user,type) + def update_post_issue(user,type,project=nil) option_number = get_option_number(user,type) - option_number.post_issue = Issue.includes(:author).where("author_id = '#{user.id}'").all.count + option_number.post_issue = post_issue_num(user,project) #Issue.includes(:author).where("author_id = '#{user.id}'").all.count update_score(option_number) end @@ -727,6 +701,23 @@ 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,project=nil) + ooption_num = get_option_number(user,type,project) + update_memo_number(user,type,project) + update_messges_for_issue(user,type,project) + update_issues_status(user,type,project) + update_replay_for_message(user,type,project) + update_replay_for_memo(user,type,project) + update_tread(user,type,project) + update_praise(user,type,project) + update_changeset(user,type,project) + update_document(user,type,project) + update_attachment(user,type,project) + update_issue_done_ratio(user,type,project) + update_post_issue(user,type,project) + update_score(ooption_num) + ooption_num end end 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/models/notificationcomment.rb b/app/models/notificationcomment.rb index 9cc658f22..ce4227a00 100644 --- a/app/models/notificationcomment.rb +++ b/app/models/notificationcomment.rb @@ -4,6 +4,7 @@ class Notificationcomment < ActiveRecord::Base include Redmine::SafeAttributes belongs_to :notificationcommented, :polymorphic => true#, :counter_cache => true belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' + belongs_to :Contestnotification validates_presence_of :notificationcommented, :author, :notificationcomments 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 diff --git a/app/models/softapplication.rb b/app/models/softapplication.rb index a572a22ba..0234bc118 100644 --- a/app/models/softapplication.rb +++ b/app/models/softapplication.rb @@ -11,7 +11,7 @@ class Softapplication < ActiveRecord::Base belongs_to :project has_many :contests, :through => :contesting_softapplications - validates_length_of :name, :maximum => 125 + validates_length_of :name, :maximum => 25 validates_length_of :application_developers, :maximum => 125 validates_length_of :android_min_version_available, :maximum => 125 diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 2009d1252..6797bc9eb 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -8,7 +8,7 @@
<%= l(:label_task_plural)%>(<%= @homework_list.count%>) - <%= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), remote: false, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if(is_teacher && @bid.homeworks.count > 0) %> + <%= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if(is_teacher && @bid.homeworks.count > 0) %> |
@@ -96,7 +96,7 @@
项目得分:
;">
- <%= homework.project.nil? ? "N/A" : project_score(homework.project) %>
+ <%= homework.project.nil? ? "N/A" : project_scores(homework.project) %>
|
@@ -106,7 +106,7 @@
提交文件:
<% if is_evaluation || is_teacher%>
- <%= link_to "打包下载", :controller => "zipdown", :action => "download_user_homework",:homework => homework, :remote => true%>
+ <%= link_to "打包下载", :controller => "zipdown", :action => "download_user_homework",:homework => homework%>
<% else %>
未开启互评功能作业不允许下载
<% end %>
diff --git a/app/views/contestnotifications/show.html.erb b/app/views/contestnotifications/show.html.erb
index eea4cc204..b6ac88008 100644
--- a/app/views/contestnotifications/show.html.erb
+++ b/app/views/contestnotifications/show.html.erb
@@ -69,7 +69,21 @@
|
|
|