Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
044bba4d0d
|
@ -16,6 +16,7 @@
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class MyController < ApplicationController
|
class MyController < ApplicationController
|
||||||
|
layout "users_base"
|
||||||
before_filter :require_login
|
before_filter :require_login
|
||||||
|
|
||||||
helper :issues
|
helper :issues
|
||||||
|
|
|
@ -56,6 +56,7 @@ class UsersController < ApplicationController
|
||||||
include WordsHelper
|
include WordsHelper
|
||||||
include GitlabHelper
|
include GitlabHelper
|
||||||
include UserScoreHelper
|
include UserScoreHelper
|
||||||
|
helper :user_score
|
||||||
|
|
||||||
# added by liuping 关注
|
# added by liuping 关注
|
||||||
|
|
||||||
|
|
|
@ -372,8 +372,8 @@ module UserScoreHelper
|
||||||
result.post_issue = 0
|
result.post_issue = 0
|
||||||
result.total_score = 0
|
result.total_score = 0
|
||||||
result.score_type =type
|
result.score_type =type
|
||||||
unless project_id.nil?
|
unless project.nil?
|
||||||
result.project_id = project_id
|
result.project_id = project.id
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
result = option_number.first
|
result = option_number.first
|
||||||
|
@ -416,12 +416,26 @@ module UserScoreHelper
|
||||||
def memo_num(user,project=nil)
|
def memo_num(user,project=nil)
|
||||||
if 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 #+ Memo.includes(:author).where("parent_id IS NULL and author_id = '#{user.id}'").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
|
||||||
|
|
||||||
|
#user.messages.where("parent_id IS NULL").count
|
||||||
else
|
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
|
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
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def memo_score(user,project=nil)
|
||||||
|
if project.nil?
|
||||||
|
User.find_by_sql("SELECT `users`.id,(SELECT COUNT(*) * 2 FROM `messages` JOIN `boards` ON boards.project_id != -1 AND messages.board_id = boards.id
|
||||||
|
WHERE messages.parent_id IS NULL AND messages.author_id = `users`.id) AS m_count
|
||||||
|
FROM `users` where id = #{user.id}")
|
||||||
|
else
|
||||||
|
User.find_by_sql("SELECT `users`.id,(SELECT COUNT(*) * 2 FROM `messages` JOIN `boards` ON boards.project_id = '#{project.id}' AND messages.board_id = boards.id
|
||||||
|
WHERE messages.parent_id IS NULL AND messages.author_id = `users`.id) AS m_count
|
||||||
|
FROM `users` where id = #{user.id}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
#更新对缺陷留言数
|
#更新对缺陷留言数
|
||||||
def update_messges_for_issue(user,type,project=nil)
|
def update_messges_for_issue(user,type,project=nil)
|
||||||
option_number = get_option_number(user,type)
|
option_number = get_option_number(user,type)
|
||||||
|
@ -437,6 +451,14 @@ module UserScoreHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def messges_for_issue_score(user,project=nil)
|
||||||
|
if project.nil?
|
||||||
|
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM journals WHERE journals.user_id = users.id AND journals.notes IS NOT NULL AND journals.notes != '') AS m_score FROM users where id = #{user.id}")
|
||||||
|
else
|
||||||
|
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM journals join issues on #{Journal.table_name}.journalized_type = 'Issue' and #{Journal.table_name}.journalized_id = #{Issue.table_name}.id WHERE journals.user_id = users.id AND journals.notes IS NOT NULL AND journals.notes != ''and #{Issue.table_name}.project_id = '#{project.id}') AS m_score FROM users where id = #{user.id}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
#更新更改缺陷状态状态次数
|
#更新更改缺陷状态状态次数
|
||||||
def update_issues_status(user,type,project=nil)
|
def update_issues_status(user,type,project=nil)
|
||||||
option_number = get_option_number(user,type)
|
option_number = get_option_number(user,type)
|
||||||
|
@ -508,8 +530,8 @@ module UserScoreHelper
|
||||||
|
|
||||||
def tread_num(user,project=nil)
|
def tread_num(user,project=nil)
|
||||||
if project.nil?
|
if project.nil?
|
||||||
result0 = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 0 and user_id = '#{user.id}'").all.count
|
result0 = PraiseTread.where("praise_tread_object_type IN ( 'Issue','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
|
pts = PraiseTread.where("praise_tread_object_type IN ( 'Issue','Message') and praise_or_tread = 0").all
|
||||||
result = []
|
result = []
|
||||||
result1 = []
|
result1 = []
|
||||||
result2 = []
|
result2 = []
|
||||||
|
@ -521,18 +543,18 @@ module UserScoreHelper
|
||||||
target_user = obj.author
|
target_user = obj.author
|
||||||
level = UserLevels.get_level(pt.user)#pt.user.get_level
|
level = UserLevels.get_level(pt.user)#pt.user.get_level
|
||||||
project = pt.project
|
project = pt.project
|
||||||
if level == 1 && target_user.id = user.id
|
if level == 1 && target_user.id == user.id
|
||||||
result << pt
|
result << pt
|
||||||
elsif level == 2 && target_user.id = user.id
|
elsif level == 2 && target_user.id == user.id
|
||||||
result1 << pt
|
result1 << pt
|
||||||
elsif level == 3 && target_user.id = user.id
|
elsif level == 3 && target_user.id == user.id
|
||||||
result2 << pt
|
result2 << pt
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
[:tread=>result0,:tead_by_one => result.count,:tread_by_two => result1.count,:tread_by_three =>result2.count]
|
{:tread=>result0,:tead_by_one => result.count,:tread_by_two => result1.count,:tread_by_three =>result2.count}
|
||||||
else
|
else
|
||||||
result0 = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 0 and user_id = '#{user.id}'").all.count
|
result0 = PraiseTread.where("praise_tread_object_type IN ( 'Issue','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
|
pts = PraiseTread.where("praise_tread_object_type IN ( 'Issue','Message') and praise_or_tread = 0").all
|
||||||
result = []
|
result = []
|
||||||
result1 = []
|
result1 = []
|
||||||
result2 = []
|
result2 = []
|
||||||
|
@ -547,15 +569,15 @@ module UserScoreHelper
|
||||||
target_user = obj.author
|
target_user = obj.author
|
||||||
level = UserLevels.get_level(pt.user)#pt.user.get_level
|
level = UserLevels.get_level(pt.user)#pt.user.get_level
|
||||||
project = pt.project
|
project = pt.project
|
||||||
if level == 1 && target_user.id = user.id
|
if level == 1 && target_user.id == user.id
|
||||||
result << pt
|
result << pt
|
||||||
elsif level == 2 && target_user.id = user.id
|
elsif level == 2 && target_user.id == user.id
|
||||||
result1 << pt
|
result1 << pt
|
||||||
elsif level == 3 && target_user.id = user.id
|
elsif level == 3 && target_user.id == user.id
|
||||||
result2 << pt
|
result2 << pt
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
[:tread=>result0,:tead_by_one => result.count,:tread_by_two => result1.count,:tread_by_three =>result2.count]
|
{:tread=>result0,:tead_by_one => result.count,:tread_by_two => result1.count,:tread_by_three =>result2.count}
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -572,7 +594,7 @@ module UserScoreHelper
|
||||||
|
|
||||||
def praise_num(user,project=nil)
|
def praise_num(user,project=nil)
|
||||||
if !project.nil?
|
if !project.nil?
|
||||||
pts = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 1").all
|
pts = PraiseTread.where("praise_tread_object_type IN ( 'Issue','Message') and praise_or_tread = 1").all
|
||||||
result = []
|
result = []
|
||||||
result1 = []
|
result1 = []
|
||||||
result2 = []
|
result2 = []
|
||||||
|
@ -587,17 +609,17 @@ module UserScoreHelper
|
||||||
target_user = obj.author
|
target_user = obj.author
|
||||||
level = UserLevels.get_level(pt.user)#pt.user.get_level
|
level = UserLevels.get_level(pt.user)#pt.user.get_level
|
||||||
project = pt.project
|
project = pt.project
|
||||||
if level == 1 && target_user.id = user.id
|
if level == 1 && target_user.id == user.id
|
||||||
result << pt
|
result << pt
|
||||||
elsif level == 2 && target_user.id = user.id
|
elsif level == 2 && target_user.id == user.id
|
||||||
result1 << pt
|
result1 << pt
|
||||||
elsif level == 3 && target_user.id = user.id
|
elsif level == 3 && target_user.id == user.id
|
||||||
result2 << pt
|
result2 << pt
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
[:praise_by_one => result.count,:praise_by_two => result1.count,:praise_by_three => result2.count]
|
{:praise_by_one => result.count,:praise_by_two => result1.count,:praise_by_three => result2.count}
|
||||||
else
|
else
|
||||||
pts = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 1").all
|
pts = PraiseTread.where("praise_tread_object_type IN ( 'Issue','Message') and praise_or_tread = 1").all
|
||||||
result = []
|
result = []
|
||||||
result1 = []
|
result1 = []
|
||||||
result2 = []
|
result2 = []
|
||||||
|
@ -612,15 +634,15 @@ module UserScoreHelper
|
||||||
target_user = obj.author
|
target_user = obj.author
|
||||||
level = UserLevels.get_level(pt.user)#pt.user.get_level
|
level = UserLevels.get_level(pt.user)#pt.user.get_level
|
||||||
project = pt.project
|
project = pt.project
|
||||||
if level == 1 && target_user.id = user.id
|
if level == 1 && target_user.id == user.id
|
||||||
result << pt
|
result << pt
|
||||||
elsif level == 2 && target_user.id = user.id
|
elsif level == 2 && target_user.id == user.id
|
||||||
result1 << pt
|
result1 << pt
|
||||||
elsif level == 3 && target_user.id = user.id
|
elsif level == 3 && target_user.id == user.id
|
||||||
result2 << pt
|
result2 << pt
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
[:praise_by_one => result.count,:praise_by_two => result1.count,:praise_by_three => result2.count]
|
{:praise_by_one => result.count,:praise_by_two => result1.count,:praise_by_three => result2.count}
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<%= l(:label_user_grade)%>:
|
<%= l(:label_user_grade)%>:
|
||||||
<%= link_to(format("%.2f" , user.user_score_attr.total_score).to_i, {:controller => 'users',
|
<!-- user.user_score_attr.total_score -->
|
||||||
|
<%= link_to(format("%.2f" ,user_scores(user,1).total_score ).to_i, {:controller => 'users',
|
||||||
:action => 'show_new_score',
|
:action => 'show_new_score',
|
||||||
:remote => true,
|
:remote => true,
|
||||||
:id => user.id
|
:id => user.id
|
||||||
|
|
|
@ -132,7 +132,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% if school_course.count < 9 %>
|
<% if school_course.count < 10 %>
|
||||||
<span>
|
<span>
|
||||||
<%= link_to "更多>>", {:controller => 'courses', :action => 'index', :school_id => nil} %>
|
<%= link_to "更多>>", {:controller => 'courses', :action => 'index', :school_id => nil} %>
|
||||||
</span>
|
</span>
|
||||||
|
@ -181,7 +181,7 @@
|
||||||
</li>
|
</li>
|
||||||
<%end%>
|
<%end%>
|
||||||
<% end; reset_cycle %>
|
<% end; reset_cycle %>
|
||||||
<% if school_course.count < 9 %>
|
<% if school_course.count < 10 %>
|
||||||
<li>
|
<li>
|
||||||
<h1></h1>
|
<h1></h1>
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@
|
||||||
该学校开设课程较少,您可以查看其他学校课程
|
该学校开设课程较少,您可以查看其他学校课程
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
<% find_all_new_hot_course(9 - school_course.count, @school_id).map do |course| %>
|
<% find_all_new_hot_course(10 - school_course.count, @school_id).map do |course| %>
|
||||||
<li class='<%= cycle("odd", "even") %>' title=<%= course.description.to_s.gsub(/<\/?.*?>/,"") %>>
|
<li class='<%= cycle("odd", "even") %>' title=<%= course.description.to_s.gsub(/<\/?.*?>/,"") %>>
|
||||||
<div class='avatar'>
|
<div class='avatar'>
|
||||||
<%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
|
<%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
|
||||||
|
|
Loading…
Reference in New Issue