Merge branch 'develop' into szzh

Conflicts:
	db/schema.rb
处理冲突
This commit is contained in:
huang 2016-01-14 15:02:30 +08:00
commit 440be81587
34 changed files with 351 additions and 216 deletions

View File

@ -456,7 +456,9 @@ class FilesController < ApplicationController
end
end
# 更新资源总数, 根据上传的附件数累加
@project.update_attribute(:attachments_count, @project.attachments_count + attachments[:files].count)
unless @project.project_score.nil?
@project.project_score.update_attribute(:attach_num, @project.project_score.attach_num + attachments[:files].count)
end
# end
# TODO: 临时用 nyan
sort_init 'created_on', 'desc'

View File

@ -203,6 +203,8 @@ class ProjectsController < ApplicationController
end
end
# 注意修改该方法的时候注意同步修改forked方法
# forked方法也会创建项目
def create
unless User.current.login?
redirect_to signin_url
@ -222,6 +224,11 @@ class ProjectsController < ApplicationController
#unless User.current.admin?
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
m = Member.new(:user => User.current, :roles => [r])
# project's score
if ProjectScore.where("project_id=?", @project.id).first.nil?
ProjectScore.create(:project_id => @project.id, :score => false)
end
# end
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}"

View File

@ -122,6 +122,9 @@ class RepositoriesController < ApplicationController
if project.save
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
m = Member.new(:user => User.current, :roles => [r])
if ProjectScore.where("project_id=?", @project.id).first.nil?
ProjectScore.create(:project_id => @project.id, :score => false)
end
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}"
@ -349,7 +352,10 @@ update
# @changesets_count = @repository.latest_changesets(@path, @rev).count
@changesets_all_count = @project.gpid.nil? ? 0 : g.project(@project.gpid).commit_count
# 访问该页面的是会后则刷新
if @changesets_all_count != @project.commits_count && @changesets_all_count != 0
if @project.project_score.nil?
ProjectScore.create(:project_id => @project.id, :score => false)
end
if @changesets_all_count != @project.project_score.changeset_num && @changesets_all_count != 0
update_commits_count(@project, @changesets_all_count)
end
# end
@ -580,7 +586,7 @@ update
private
# 更新项目统计数
def update_commits_count project, count
project.update_attribute(:commits_count, count)
project.project_score.update_attribute(:changeset_num, count)
end
def find_repository

View File

@ -683,7 +683,7 @@ class StudentWorkController < ApplicationController
if !params[:name].nil?
condition = "%#{params[:name].strip}%".gsub(" ","")
end
@project_ids = Project.where("user_id = #{User.current.id} and name like '#{condition}'")
@project_ids = Project.visible.where("user_id = #{User.current.id} and name like '#{condition}'")
@first = params[:first].to_i
respond_to do |format|
format.js

View File

@ -52,7 +52,7 @@ module ApplicationHelper
# 获取项目/课程总分
# 发布缺陷 4分 回复缺陷 1分 提交一次 4分 讨论帖子 2分 回复帖子 1分 发布新闻 1分
def static_project_score obj
score = obj.issues_count * 4 + obj.journals_count + obj.commits_count * 4 + obj.boards_count * 2 + obj.boards_reply_count + obj.news_count + obj.attachments_count * 5
score = obj.issue_num * 4 + obj.issue_journal_num + obj.changeset_num * 4 + obj.board_num * 2 + obj.board_message_num + obj.news_num + obj.attach_num * 5
end
# 获取组织成员中文名字

View File

@ -1,6 +1,7 @@
require 'elasticsearch/model'
class Course < ActiveRecord::Base
include Redmine::SafeAttributes
include ApplicationHelper
STATUS_ACTIVE = 1
STATUS_CLOSED = 5

View File

@ -20,8 +20,8 @@ class ForgeActivity < ActiveRecord::Base
validates :forge_act_id,presence: true
validates :forge_act_type, presence: true
has_many :user_acts, :class_name => 'UserAcivity',:as =>:act
after_save :add_user_activity, :add_org_activity, :add_acts_count
before_destroy :destroy_user_activity, :destroy_org_activity, :decrease_acts_count
after_save :add_user_activity, :add_org_activity
before_destroy :destroy_user_activity, :destroy_org_activity
#在个人动态里面增加当前动态
def add_user_activity
@ -45,21 +45,6 @@ class ForgeActivity < ActiveRecord::Base
end
end
# 更新动态数
def add_acts_count
if self.project
count = self.project.acts_count + 1
self.project.update_attribute(:acts_count, count)
end
end
def decrease_acts_count
if self.project
count = self.project.acts_count - 1
self.project.update_attribute(:acts_count, count)
end
end
def add_org_activity
org_activity = OrgActivity.where("org_act_type = '#{self.forge_act_type.to_s}' and org_act_id = #{self.forge_act_id}").first
if org_activity

View File

@ -19,6 +19,7 @@ class Issue < ActiveRecord::Base
include Redmine::SafeAttributes
include Redmine::Utils::DateCalculation
include UserScoreHelper
include ApplicationHelper
belongs_to :project,:touch=> true
belongs_to :tracker
belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id'
@ -173,14 +174,18 @@ class Issue < ActiveRecord::Base
# 创建issue的时候issues_count加1
def add_issues_count
issue_count = self.project.issues_count + 1
self.project.update_attribute(:issues_count, issue_count)
unless self.project.project_score.nil?
issue_count = self.project.project_score.issue_num + 1
self.project.project_score.update_attribute(:issue_num, issue_count)
end
end
# 删除issue的时候issues_count减1
def decrease_issues_count
issue_count = self.project.issues_count - 1
self.project.update_attribute(:issues_count, issue_count)
unless self.project.project_score.nil?
issue_count = self.project.project_score.issue_num - 1
self.project.project_score.update_attribute(:issue_num, issue_count)
end
end
# 更新缺陷

View File

@ -225,9 +225,9 @@ class Journal < ActiveRecord::Base
# issue留言总数更新
def add_journals_count
unless self.issue.project.nil? && self.journalized_type == "Issue"
if !self.issue.project.nil? && self.journalized_type == "Issue" && self.issue.project.project_score.nil?
project = self.issue.project
project.update_attribute(:journals_count, project.journals_count + 1)
project.project_score.update_attribute(:issue_journal_num, project.project_score.journals_count + 1)
end
end
end

View File

@ -36,7 +36,6 @@ class Message < ActiveRecord::Base
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
# 课程动态
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
has_many :user_acts, :class_name => 'UserActivity',:as =>:user_act ,:dependent => :destroy
# end
# 课程/项目 消息
@ -129,14 +128,32 @@ class Message < ActiveRecord::Base
# 发帖精辟更新发帖总数
def add_boards_count
if self.project
# 讨论区
if self.parent_id.nil?
count = self.project.boards_count + 1
self.project.update_attribute(:boards_count, count)
else # 回复
count = self.project.boards_reply_count + 1
self.project.update_attribute(:boards_reply_count, count)
unless self.project.project_score.nil?
if self.project
# 讨论区
if self.parent_id.nil?
count = self.project.project_score.board_num + 1
self.project.project_score.update_attribute(:board_num, count)
else # 回复
count = self.project.project_score.board_message_num + 1
self.project.project_score.update_attribute(:board_message_num, count)
end
end
end
end
# 删除帖子的时候更新帖子总数, 删除回复的时候总数不减少
def decrease_boards_count
unless self.project.project_score.nil?
if self.project && self.parent_id.nil?
# 讨论区
if self.parent_id.nil?
count = self.project.project_score.board_num - 1
self.project.project_score.update_attribute(:board_num, count)
else # 回复
count = self.project.project_score.board_message_num - 1
self.project.project_score.update_attribute(:board_message_num, count)
end
end
end
end
@ -326,20 +343,6 @@ class Message < ActiveRecord::Base
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::MESSAGE
end
# 删除帖子的时候更新帖子总数, 删除回复的时候总数不减少
def decrease_boards_count
if self.project && self.parent_id.nil?
# 讨论区
if self.parent_id.nil?
count = self.project.boards_count - 1
self.project.update_attribute(:boards_count, count)
else # 回复
count = self.project.boards_reply_count - 1
self.project.update_attribute(:boards_reply_count, count)
end
end
end
# 课程成员得分(英雄榜)
def act_as_student_score
if self.course

View File

@ -116,9 +116,16 @@ class News < ActiveRecord::Base
private
def add_news_count
if self.project
count = self.project.news_count + 1
self.project.update_attribute(:news_count, count)
if self.project && !self.project.project_score.nil?
count = self.project.project_score.news_num + 1
self.project.project_score.update_attribute(:news_num, count)
end
end
def decrease_news_count
if self.project && !self.project.project_score.nil?
count = self.project.project_score.news_num - 1
self.project.project_score.update_attribute(:news_num, count)
end
end
@ -176,13 +183,6 @@ class News < ActiveRecord::Base
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::NEWS
end
def decrease_news_count
if self.project
count = self.project.news_count - 1
self.project.update_attribute(:news_count, count)
end
end
def send_mail
Mailer.run.news_added(self) if Setting.notified_events.include?('news_added')
end

View File

@ -1,6 +1,7 @@
class OrgDocumentComment < ActiveRecord::Base
attr_accessible :content, :creator_id, :organization_id, :parent_id, :reply_id, :title,:sticky,:locked
include Redmine::SafeAttributes
include ApplicationHelper
belongs_to :organization
belongs_to :creator, :class_name => 'User', :foreign_key => 'creator_id'
has_many :editor_of_documents, :dependent => :destroy

View File

@ -1,6 +1,7 @@
class Poll < ActiveRecord::Base
#attr_accessible :closed_at, :polls_group_id, :polls_name, :polls_status, :polls_type, :published_at, :user_id
include Redmine::SafeAttributes
include ApplicationHelper
belongs_to :user
has_many :poll_questions, :dependent => :destroy,:order => "#{PollQuestion.table_name}.question_number"

View File

@ -155,7 +155,7 @@ class Project < ActiveRecord::Base
# 创建project之后默认创建一个board之后的board去掉了board的概念
after_create :create_board_sync,:acts_as_forge_activities,:create_project_ealasticsearch_index
before_destroy :delete_all_members,:delete_project_ealasticsearch_index
# after_update :update_project_ealasticsearch_index
after_update :update_project_ealasticsearch_index
def remove_references_before_destroy
return if self.id.nil?
Watcher.delete_all ['watchable_id = ?', id]
@ -1223,26 +1223,27 @@ class Project < ActiveRecord::Base
self.__elasticsearch__.index_document
end
end
# def update_project_ealasticsearch_index
# if self.is_public #如果是初次更新成为公开的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性
# begin
# self.__elasticsearch__.update_document
# rescue => e
# self.__elasticsearch__.index_document
# end
# else #如果是更新成为私有的,那么索引就要被删除
# begin
# self.__elasticsearch__.delete_document
# rescue => e
#
# end
# end
# end
def update_project_ealasticsearch_index
if self.is_public #如果是初次更新成为公开的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性
begin
self.__elasticsearch__.update_document
rescue => e
self.__elasticsearch__.index_document
end
else #如果是更新成为私有的,那么索引就要被删除
begin
self.__elasticsearch__.delete_document
rescue => e
end
end
end
def delete_project_ealasticsearch_index
begin
self.__elasticsearch__.delete_document
rescue => e
end
end

View File

@ -3,10 +3,17 @@
<% student_num = studentCount(@course) %>
<% course_file_num = visable_attachemnts_incourse(@course).count%>
<div class="pr_info_logo fl mr10 mb5">
<% if @course.id == 370 %>
<img src="/images/course/boutique.png" width="50" height="auto" alt="精品" class="boutiqueP" />
<% end %>
<!--<a href="#"><img src="images/courses/pic_courses.jpg" width="60" height="60" alt="logo" /></a>-->
<%= image_tag(url_to_avatar(@course), :width => "60", :height => "60") %>
</div>
<div class="pr_info_id fl mb5 f14"><%= @course.is_public == 0 ? "私有课程" : "公开课程" %></div>
<div class="pr_info_id fl mb5 f14"><%= @course.is_public == 0 ? "私有课程" : "公开课程" %>
<% if @course.id == 370 %>
<img src="/images/course/medal.png" alt="精品课程" style="vertical-align:bottom;" class="ml5" />
<% end %>
</div>
<div class="pr_info_id fl f14">
ID:<%= @course.id%>
</div>

View File

@ -76,9 +76,9 @@
<div class="cl"></div>
<div>
<% if @project.project_type == 0 %>
<% unless static_project_score(@project) == 0 %>
<% unless static_project_score(@project.project_score) == 0 %>
<span class="fb f14 "><%= l(:label_project_score)%> :</span>
<%= link_to(format("%.2f" ,static_project_score(@project) ).to_i,
<%= link_to(format("%.2f" ,static_project_score(@project.project_score)).to_i,
{:controller => 'projects',
:action => 'show_projects_score',
:remote => true,
@ -95,8 +95,8 @@
<% unless @project.enabled_modules.where("name = 'files'").empty? %>
<span>|&nbsp;</span>
<%= l(:project_module_attachments) %>
<% @project.attachments_count %>
<%= link_to "#{@project.attachments_count}", project_files_path(@project), :class => 'info_foot_num c_blue', :id=>'project_files_count_info' %></span>
<% @project.project_score.attach_num %>
<%= link_to "#{@project.project_score.attach_num }", project_files_path(@project), :class => 'info_foot_num c_blue', :id=>'project_files_count_info' %></span>
<% end %>
</div>
<div class="cl"></div>

View File

@ -173,7 +173,7 @@
<% time=project.updated_on %>
<% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>
<p><span class="captainName" title="<%=(User.find project.user_id).show_name %>"><%=(User.find project.user_id).show_name %></span><span style="vertical-align: top;">(组长)</span></p>
<p><%=time_from_now time %></p>
<p><%=time_from_now time %>&nbsp;&nbsp;<%= project.commits_count %>提交</p>
<div class="relatePInfo" id="relatePInfo_<%=project.id %>_<%=activity.id %>">
项目名称:<%=project.name %><br />
创建者:<%=(User.find project.user_id).show_name %>(组长)<br />

View File

@ -23,7 +23,7 @@
创建时间:<%= format_time(project.created_on) %>
</div>
<div class="homepagePostDate fl ml15">
更新时间:<%= format_time(ForgeActivity.where("forge_act_type='#{activity.class}' and forge_act_id =#{activity.id}").first.updated_at) %>
更新时间:<%= format_time(ForgeActivity.where("forge_act_type='ProjectCreateInfo' and forge_act_id =#{project.id}").first.updated_at) %>
</div>
<div class="cl"></div>
<div class="homepagePostSetting" id="act-<%= user_activity_id %>" style="visibility: hidden">

View File

@ -1,14 +1,14 @@
<div class="subNav">
<%= link_to l(:label_activity), {:controller => 'projects', :action => 'show', :id => @project.id}, :class => "f14 c_blue02" %>
<% unless @project.acts_count == 0 %>
<a class="subnav_num">(<%= @project.acts_count %>)</a>
<% unless ForgeActivity.where("project_id = ?", @project.id).count == 0 %>
<a class="subnav_num">(<%= ForgeActivity.where("project_id = ?", @project.id).count %>)</a>
<% end %>
</div>
<% unless @project.enabled_modules.where("name = 'issue_tracking'").empty? %>
<div class="subNav">
<%= link_to l(:label_issue_tracking), project_issues_path(@project, :remote => true), :class => "f14 c_blue02" %>
<% if @project.issues_count > 0 %>
<a class="subnav_num">(<%= @project.issues_count %>)</a>
<% if @project.project_score.issue_num > 0 %>
<a class="subnav_num">(<%= @project.project_score.issue_num %>)</a>
<% end %>
<% if User.current.member_of?(@project) %>
@ -19,8 +19,8 @@
<% unless @project.enabled_modules.where("name = 'boards'").empty? %>
<div class="subNav">
<%= link_to l(:project_module_boards), project_boards_path(@project), :class => "f14 c_blue02" %>
<% unless @project.boards_count == 0 %>
<a class="subnav_num">(<%= @project.boards_count %>)</a>
<% unless @project.project_score.board_num == 0 %>
<a class="subnav_num">(<%= @project.project_score.board_num %>)</a>
<% end %>
<% if User.current.member_of?(@project) %>
<%= link_to "+"+l(:project_module_boards_post), project_boards_path(@project, :flag => true), :layout => 'base_projects', :class => "subnav_green ml105" %>
@ -30,8 +30,8 @@
<% unless @project.enabled_modules.where("name = 'files'").empty? %>
<div class="subNav">
<%= link_to l(:project_module_files), project_files_path(@project), :class => "f14 c_blue02" %>
<% unless @project.attachments_count == 0 %>
<%= link_to "(#{@project.attachments_count})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
<% unless @project.project_score.attach_num == 0 %>
<%= link_to "(#{@project.project_score.attach_num})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
<% end %>
<% if User.current.member_of?(@project) %>
<%#= link_to "+"+l(:label_upload_source), project_files_path(@project,:flag => true), :class => "subnav_green ml95" %>

View File

@ -1,14 +1,14 @@
<div class="subNav">
<%= link_to l(:label_activity), {:controller => 'projects', :action => 'show', :id => @project.id}, :class => "f14 c_blue02" %>
<% unless @project.acts_count == 0 %>
<a class="subnav_num">(<%= @project.acts_count %>)</a>
<% unless ForgeActivity.where("project_id = ?", @project.id).count == 0 %>
<a class="subnav_num">(<%= ForgeActivity.where("project_id = ?", @project.id).count %>)</a>
<% end %>
</div>
<% unless @project.enabled_modules.where("name = 'boards'").empty? %>
<div class="subNav">
<%= link_to l(:project_module_boards), project_boards_path(@project), :class => "f14 c_blue02" %>
<% unless @project.boards_count == 0 %>
<a class="subnav_num">(<%= @project.boards_count %>)</a>
<% unless @project.project_score.board_num == 0 %>
<a class="subnav_num">(<%= @project.project_score.board_num %>)</a>
<% end %>
<% if User.current.member_of?(@project) %>
<%= link_to "+"+l(:project_module_boards_post), project_boards_path(@project, :flag => true), :layout => 'base_projects', :class => "subnav_green ml105" %>
@ -18,8 +18,8 @@
<% unless @project.enabled_modules.where("name = 'files'").empty? %>
<div class="subNav">
<%= link_to l(:project_module_files), project_files_path(@project), :class => "f14 c_blue02" %>
<% unless @project.attachments_count == 0 %>
<%= link_to "(#{@project.attachments_count})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
<% unless @project.project_score.attach_num == 0 %>
<%= link_to "(#{@project.project_score.attach_num})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
<% end %>
<% if User.current.member_of?(@project) %>
<%= link_to "+"+l(:label_upload_source), project_files_path(@project,:flag => true), :class => "subnav_green ml95" %>

View File

@ -18,9 +18,13 @@
<div class="homepagePostTitle break_word" >
<%= link_to project.name, project_path(project.id,:host=>Setting.host_course), :class => "postGrey" %>
</div>
<div class="homepagePostDate">
<div class="homepagePostDate fl">
创建时间:<%= format_time(project.created_on) %>
</div>
<div class="homepagePostDate fl ml15">
更新时间:<%= format_time(ForgeActivity.where("forge_act_type='ProjectCreateInfo' and forge_act_id =#{project.id}").first.updated_at) %>
</div>
<div class="cl"></div>
<div class="homepagePostSetting" id="act-<%= user_activity_id %>" style="visibility: hidden">
<ul>
<li class="homepagePostSettingIcon">

View File

@ -1,9 +1,9 @@
<div style="color: #64BDD9;font-size: 14px;font-weight: bold"><%= l(:label_projects_score) %></div>
<div> = <%= l(:label_code_submit_score) %> + <%= l(:label_issue_score) %> + <%= l(:label_file_attachment_score) %> + <%= l(:label_topic_score) %> + <%= l(:label_news_score) %></div>
<div> = <%= @project.commits_count * 4 %> +
<%= @project.issues_count * 4 + @project.journals_count %> +
<%= @project.attachments_count * 5 %> +
<%= @project.boards_count * 2 + @project.boards_reply_count %> +
<%= @project.news_count %>
<div> = <%= @project.project_score.changeset_num * 4 %> +
<%= @project.project_score.issue_num * 4 + @project.project_score.issue_journal_num %> +
<%= @project.project_score.attach_num * 5 %> +
<%= @project.project_score.board_num * 2 + @project.project_score.board_message_num %> +
<%= @project.project_score.news_num %>
</div>
<div> = <%= static_project_score(@project) %></div>
<div> = <%= static_project_score(@project.project_score) %></div>

View File

@ -1,14 +1,14 @@
<div class="subNav">
<%= link_to l(:label_activity), {:controller => 'projects', :action => 'show', :id => @project.id}, :class => "f14 c_blue02" %>
<% unless @project.acts_count == 0 %>
<a class="subnav_num">(<%= @project.acts_count %>)</a>
<% unless ForgeActivity.where("project_id = ?", @project.id).count == 0 %>
<a class="subnav_num">(<%= ForgeActivity.where("project_id = ?", @project.id).count %>)</a>
<% end %>
</div>
<% unless @project.enabled_modules.where("name = 'issue_tracking'").empty? %>
<div class="subNav">
<%= link_to l(:label_issue_tracking), project_issues_path(@project), :class => "f14 c_blue02" %>
<% if @project.issues_count > 0 %>
<a class="subnav_num">(<%= @project.issues_count %>)</a>
<% if @project.project_score.issue_num > 0 %>
<a class="subnav_num">(<%= @project.project_score.issue_num %>)</a>
<% end %>
<% if User.current.member_of?(@project) %>
<%= link_to "+"+l(:label_release_issue), new_project_issue_path(@project) , :class => "subnav_green" %>
@ -18,8 +18,8 @@
<% unless @project.enabled_modules.where("name = 'boards'").empty? %>
<div class="subNav">
<%= link_to l(:project_module_boards), project_boards_path(@project), :class => "f14 c_blue02" %>
<% unless @project.boards_count == 0 %>
<a class="subnav_num">(<%= @project.boards_count %>)</a>
<% unless @project.project_score.board_num == 0 %>
<a class="subnav_num">(<%= @project.project_score.board_num %>)</a>
<% end %>
<% if User.current.member_of?(@project) %>
<%= link_to "+"+l(:project_module_boards_post), project_boards_path(@project, :flag => true), :layout => 'base_projects', :class => "subnav_green ml105" %>
@ -29,8 +29,8 @@
<% unless @project.enabled_modules.where("name = 'files'").empty? %>
<div class="subNav">
<%= link_to l(:project_module_files), project_files_path(@project), :class => "f14 c_blue02" %>
<% unless @project.attachments_count == 0 %>
<%= link_to "(#{@project.attachments_count})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
<% unless @project.project_score.attach_num == 0 %>
<%= link_to "(#{@project.project_score.attach_num})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
<% end %>
<% if User.current.member_of?(@project) %>
<%= link_to "+"+l(:label_upload_source), project_files_path(@project,:flag => true), :class => "subnav_green ml95" %>

View File

@ -12,7 +12,7 @@
<td width="35%">
<table>
<tr class="info_font" style="color: #64BDD9;font-size: 14px;font-weight: bold"><td><%= l(:label_projects_score) %></td></tr>
<tr class="buttons_for_score" style="margin-top:30px;margin-left:144px"><td><span style="color:#ec6300"><%= static_project_score(@project) %></span></td></tr>
<tr class="buttons_for_score" style="margin-top:30px;margin-left:144px"><td><span style="color:#ec6300"><%= static_project_score(@project.project_score) %></span></td></tr>
</table>
</td>
</tr>
@ -22,22 +22,22 @@
<div class="tabs_new">
<ul>
<li>
<%= link_to l(:label_projects_score),"javascript:void(0)", :onclick => "show_div('project_score_index')"%> : <%= static_project_score(@project) %>
<%= link_to l(:label_projects_score),"javascript:void(0)", :onclick => "show_div('project_score_index')"%> : <%= static_project_score(@project.project_score) %>
</li>
<li>
<%= link_to l(:label_code_submit_score), "javascript:void(0)", :onclick => "show_div('code_submit_score_index')" %> : <%= @project.commits_count * 4 %>
<%= link_to l(:label_code_submit_score), "javascript:void(0)", :onclick => "show_div('code_submit_score_index')" %> : <%= @project.project_score.changeset_num * 4 %>
</li>
<li>
<%= link_to l(:label_issue_score), "javascript:void(0)", :onclick => "show_div('issue_score_index')"%> : <%= @project.issues_count * 4 + @project.journals_count %>
<%= link_to l(:label_issue_score), "javascript:void(0)", :onclick => "show_div('issue_score_index')"%> : <%= @project.project_score.issue_num * 4 + @project.project_score.issue_journal_num %>
</li>
<li>
<%= link_to l(:label_file_attachment_score), "javascript:void(0)", :onclick => "show_div('issue_score_index')"%> : <%= @project.attachments_count * 5 %>
<%= link_to l(:label_file_attachment_score), "javascript:void(0)", :onclick => "show_div('issue_score_index')"%> : <%= @project.project_score.attach_num * 5 %>
</li>
<li>
<%= link_to l(:label_topic_score), "javascript:void(0)", :onclick => "show_div('projects_topic_score_index')"%> : <%= @project.boards_count * 2 + @project.boards_reply_count %>
<%= link_to l(:label_topic_score), "javascript:void(0)", :onclick => "show_div('projects_topic_score_index')"%> : <%= @project.project_score.board_num * 2 + @project.project_score.board_message_num %>
</li>
<li>
<%= link_to l(:label_news_score), "javascript:void(0)", :onclick => "show_div('news_score_index')"%> : <%= @project.news_count %>
<%= link_to l(:label_news_score), "javascript:void(0)", :onclick => "show_div('news_score_index')"%> : <%= @project.project_score.news_num %>
</li>
</ul>
</div>

View File

@ -173,7 +173,7 @@
<% time=project.updated_on %>
<% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>
<p><span class="captainName" title="<%=(User.find project.user_id).show_name %>"><%=(User.find project.user_id).show_name %></span><span style="vertical-align: top;">(组长)</span></p>
<p><%=time_from_now time %></p>
<p><%=time_from_now time %>&nbsp;&nbsp;<%= project.commits_count %>提交</p>
<div class="relatePInfo" id="relatePInfo_<%=project.id %>_<%=activity.id %>">
项目名称:<%=project.name %><br />
创建者:<%=(User.find project.user_id).show_name %>(组长)<br />

View File

@ -23,7 +23,7 @@
创建时间:<%= format_time(project.created_on) %>
</div>
<div class="homepagePostDate fl ml15">
更新时间:<%= format_time(ForgeActivity.where("forge_act_type='#{activity.class}' and forge_act_id =#{activity.id}").first.updated_at) %>
更新时间:<%= format_time(ForgeActivity.where("forge_act_type='ProjectCreateInfo' and forge_act_id =#{project.id}").first.updated_at) %>
</div>
<div class="cl"></div>
<div class="homepagePostSetting" id="act-<%= user_activity_id %>" style="visibility: hidden">

View File

@ -174,7 +174,7 @@
<% time=project.updated_on %>
<% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>
<p><span class="captainName" title="<%=(User.find project.user_id).show_name %>"><%=(User.find project.user_id).show_name %></span><span style="vertical-align: top;">(组长)</span></p>
<p><%=time_from_now time %></p>
<p><%=time_from_now time %>&nbsp;&nbsp;<%= project.commits_count %>提交</p>
<div class="relatePInfo" id="relatePInfo_<%=project.id %>_<%=homework_common.id %>">
项目名称:<%=project.name %><br />
创建者:<%=(User.find project.user_id).show_name %>(组长)<br />

View File

@ -0,0 +1,42 @@
class UpdateForgeAndUserActivity < ActiveRecord::Migration
def up
user_count = UserActivity.all.count / 30 + 2
transaction do
for i in 1 ... user_count do i
UserActivity.page(i).per(30).each do |user_act|
if user_act.act_type == 'Issue'
if user_act.act
if user_act.act.journals.count > 0
user_act.updated_at = user_act.act.journals.maximum("created_on")
user_act.save
end
else
user_act.destroy
end
end
end
end
end
for_count = ForgeActivity.all.count / 30 + 2
transaction do
for i in 1 ... for_count do i
ForgeActivity.page(i).per(30).each do |for_act|
if for_act.forge_act_type == 'Issue'
if for_act.forge_act
if for_act.forge_act.journals.count > 0
for_act.updated_at = for_act.forge_act.journals.maximum("created_on")
for_act.save
end
else
for_act.destroy
end
end
end
end
end
end
def down
end
end

View File

@ -0,0 +1,6 @@
class AddBoardNumToProjectScore < ActiveRecord::Migration
def change
add_column :project_scores, :board_num, :integer, :default => false
add_column :project_scores, :attach_num, :integer, :default => false
end
end

View File

@ -0,0 +1,61 @@
class UpdateProjectScore < ActiveRecord::Migration
def up
project_count = Project.all.count / 30 + 2
transaction do
for i in 1 ... project_count do i
Project.page(i).per(30).each do |project|
puts project.id
if ProjectScore.where("project_id=?", project.id).first.nil?
puts "create project ==>#{project.id}"
ProjectScore.create(:project_id => project.id, :score => false)
end
unless project.project_score.nil?
# update boards
unless project.boards.first.nil?
boards_count = project.boards.first.topics.count
project.project_score.update_attribute(:board_num, boards_count)
end
# update boards reply
unless project.boards.first.nil?
messages_count = Message.where("board_id =? and parent_id is not ?", project.boards.first.id, nil).count
project.project_score.update_attribute(:board_message_num, messages_count)
end
# update issues
unless project.issues.nil?
issues_count = project.issues.count
project.project_score.update_attribute(:issue_num, issues_count)
end
# update issue's journal
# if !project.project_score.nil? && !project.project_score.issue_journal_num.nil?
# project.project_score.update_attribute(:issue_journal_num, project.project_score.issue_journal_num)
# end
# update news
unless project.news.nil?
news_count = project.news.count
project.project_score.update_attribute(:news_num, news_count)
end
# update attach
unless project.attachments.nil?
attachments_count = project.attachments.count
project.project_score.update_attribute(:attach_num, attachments_count)
end
# update commits
unless project.gpid.nil?
g = Gitlab.client
begin
puts project.id
count = g.project(project.gpid).commit_count
rescue
logger.error("The project's rep is not exit!")
end
project.project_score.update_attribute(:changeset_num, count)
end
end
end
end
end
end
def down
end
end

View File

@ -1365,6 +1365,8 @@ ActiveRecord::Schema.define(:version => 20160112085834) do
t.integer "documents_num", :default => 0
t.integer "changeset_num", :default => 0
t.integer "board_message_num", :default => 0
t.integer "board_num", :default => 0
t.integer "attach_num", :default => 0
end
create_table "project_statuses", :force => true do |t|

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -1255,3 +1255,4 @@ div.disable_link {background-color: #c1c1c1 !important;}
.boxShadow {box-shadow:0px 2px 8px rgba(146, 153, 169, 0.5);}
.fn {font-weight:normal}
.boutiqueP {position:absolute; left:0px; top:0px;}