<%= watcher_link(@topic, User.current) %>
<%= link_to(
diff --git a/app/views/praise_tread/_praise_tread.html.erb b/app/views/praise_tread/_praise_tread.html.erb
index 5fee2a593..8d2545f91 100644
--- a/app/views/praise_tread/_praise_tread.html.erb
+++ b/app/views/praise_tread/_praise_tread.html.erb
@@ -1,57 +1,101 @@
<% if User.current.logged? %>
-
+ <% if horizontal %>
+
+
- <% @is_valuate = is_praise_or_tread(obj,user_id)%>
- <% if @is_valuate.size > 0 %>
- <% @flag = @is_valuate.first.praise_or_tread %>
- <% if @flag == 1 %>
-
-
- <%= image_tag "/images/praise_tread/praise_false.png" , weight:"22px", height:"22px",:title => l(:label_issue_praise_over) %> |
-
-
- <%= get_praise_num(obj)%> |
-
-
-
- <%= image_tag "/images/praise_tread/tread_false.png",weight:"22px", height:"22px",:title => l(:label_issue_appraise_over) %> |
-
-
-
- <% elsif @flag == 0 %>
-
-
-
- <%= image_tag "/images/praise_tread/praise_false.png",weight:"22px", height:"22px", :title => l(:label_issue_appraise_over) %> |
-
-
-
- <%= get_praise_num(obj)%> |
-
-
- <%= image_tag "/images/praise_tread/tread_false.png",weight:"22px", height:"22px",:title => l(:label_issue_tread_over) %> |
-
-
- <% end %>
+ <% @is_valuate = is_praise_or_tread(obj,user_id)%>
+ <% if @is_valuate.size > 0 %>
+ <% @flag = @is_valuate.first.praise_or_tread %>
+ <% if @flag == 1 %>
+
+
+ <%= image_tag "/images/praise_tread/praise_false.png" , weight:"22px", height:"22px",:title => l(:label_issue_praise_over) %> |
+ <%= get_praise_num(obj)%> |
+ <%= image_tag "/images/praise_tread/tread_false.png",weight:"22px", height:"22px",:title => l(:label_issue_appraise_over) %> |
+
+
- <% else %>
-
-
-
- <%= link_to image_tag("/images/praise_tread/praise_true.png",weight:"22px", height:"22px",:title => l(:label_issue_praise)),
- :controller=>"praise_tread",:action=>"praise_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class%> |
-
-
- <%= get_praise_num(obj)%> |
-
-
- <%= link_to image_tag("/images/praise_tread/tread_true.png",weight:"22px", height:"22px",:title => l(:label_issue_tread)),:controller=>"praise_tread",
- :action=>"tread_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class %> |
-
-
-
- <% end %>
-
+ <% elsif @flag == 0 %>
-<% end %>
+
+
+ <%= image_tag "/images/praise_tread/praise_false.png",weight:"22px", height:"22px", :title => l(:label_issue_appraise_over) %> |
+ <%= get_praise_num(obj)%> |
+ <%= image_tag "/images/praise_tread/tread_false.png",weight:"22px", height:"22px",:title => l(:label_issue_tread_over) %> |
+
+
+ <% end %>
+
+ <% else %>
+
+
+
+ <%= link_to image_tag("/images/praise_tread/praise_true.png",weight:"22px", height:"22px",:title => l(:label_issue_praise)),
+ :controller=>"praise_tread",:action=>"praise_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class,:horizontal => horizontal %> |
+ <%= get_praise_num(obj)%> |
+ <%= link_to image_tag("/images/praise_tread/tread_true.png",weight:"22px", height:"22px",:title => l(:label_issue_tread)),:controller=>"praise_tread",
+ :action=>"tread_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class,:horizontal => horizontal %> |
+
+
+
+ <% end %>
+
+
+ <% else %>
+
+
+
+ <% @is_valuate = is_praise_or_tread(obj,user_id)%>
+ <% if @is_valuate.size > 0 %>
+ <% @flag = @is_valuate.first.praise_or_tread %>
+ <% if @flag == 1 %>
+
+
+ <%= image_tag "/images/praise_tread/praise_false.png" , weight:"22px", height:"22px",:title => l(:label_issue_praise_over) %> |
+
+
+ <%= get_praise_num(obj)%> |
+
+
+
+ <%= image_tag "/images/praise_tread/tread_false.png",weight:"22px", height:"22px",:title => l(:label_issue_appraise_over) %> |
+
+
+
+ <% elsif @flag == 0 %>
+
+
+
+ <%= image_tag "/images/praise_tread/praise_false.png",weight:"22px", height:"22px", :title => l(:label_issue_appraise_over) %> |
+
+
+
+ <%= get_praise_num(obj)%> |
+
+
+ <%= image_tag "/images/praise_tread/tread_false.png",weight:"22px", height:"22px",:title => l(:label_issue_tread_over) %> |
+
+
+ <% end %>
+
+ <% else %>
+
+
+
+ <%= link_to image_tag("/images/praise_tread/praise_true.png",weight:"22px", height:"22px",:title => l(:label_issue_praise)),
+ :controller=>"praise_tread",:action=>"praise_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class ,:horizontal => horizontal %> |
+
+
+ <%= get_praise_num(obj)%> |
+
+
+ <%= link_to image_tag("/images/praise_tread/tread_true.png",weight:"22px", height:"22px",:title => l(:label_issue_tread)),:controller=>"praise_tread",
+ :action=>"tread_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class ,:horizontal => horizontal %> |
+
+
+
+ <% end %>
+
+ <% end %>
+ <% end %>
diff --git a/app/views/praise_tread/praise_minus.js.erb b/app/views/praise_tread/praise_minus.js.erb
index 74f7d6bfe..ab298ba2e 100644
--- a/app/views/praise_tread/praise_minus.js.erb
+++ b/app/views/praise_tread/praise_minus.js.erb
@@ -1,3 +1,3 @@
$('#praise_tread').html('<%= j(
-render :partial => "/praise_tread/praise_tread",:locals => {:obj => @obj,:show_flag => false,:user_id => User.current.id}
+render :partial => "/praise_tread/praise_tread",:locals => {:obj => @obj,:show_flag => false,:user_id => User.current.id,:horizontal=>@horizontal}
)%>');
diff --git a/app/views/praise_tread/praise_plus.js.erb b/app/views/praise_tread/praise_plus.js.erb
index c2584dcd2..d56ff0e68 100644
--- a/app/views/praise_tread/praise_plus.js.erb
+++ b/app/views/praise_tread/praise_plus.js.erb
@@ -1,4 +1,4 @@
$('#praise_tread_<%= @obj.id %>').html('<%= j(
-render :partial => "/praise_tread/praise_tread",:locals => {:obj => @obj,:user_id => User.current.id}
+render :partial => "/praise_tread/praise_tread",:locals => {:obj => @obj,:user_id => User.current.id,:horizontal => @horizontal}
)%>');
diff --git a/app/views/praise_tread/tread_plus.js.erb b/app/views/praise_tread/tread_plus.js.erb
index 89efec2dc..1104440ec 100644
--- a/app/views/praise_tread/tread_plus.js.erb
+++ b/app/views/praise_tread/tread_plus.js.erb
@@ -1,5 +1,5 @@
$('#praise_tread_<%= @obj.id %>').html('<%= j(
-render :partial => "/praise_tread/praise_tread",:locals => {:obj => @obj,:user_id => User.current.id}
+render :partial => "/praise_tread/praise_tread",:locals => {:obj => @obj,:user_id => User.current.id,:horizontal => @horizontal}
)%>');
diff --git a/lib/tasks/userscore.rake b/lib/tasks/userscore.rake
index eefca6d7a..144b9c9b9 100644
--- a/lib/tasks/userscore.rake
+++ b/lib/tasks/userscore.rake
@@ -14,47 +14,136 @@ namespace :user_score do
Message.includes(:author).where("parent_id IS NULL").all.each do |m|
users[m.author.id] = users[m.author.id].to_i + 2
end
- puts ":post_message calculate Completed. users count: #{users.count}"
+ puts ":post_message calculate Completed. collaboration users count: #{users.count}"
# 对缺陷的留言
Journal.includes(:user).all.each do |j|
users[j.user.id] = users[j.user.id].to_i + 1
end
- puts ":post_issue calculate Completed. users count: #{users.count}"
+ puts ":post_issue calculate Completed. collaboration users count: #{users.count}"
# 更改一次缺陷状态
Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id'").each do |j|
users[j.user.id] = users[j.user.id].to_i + 1
end
- puts ":change_issue_status calculate Completed. users count: #{users.count}"
+ puts ":change_issue_status calculate Completed. collaboration users count: #{users.count}"
# 对留言的回复
JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL").each do |jfm|
users[jfm.user.id] = users[jfm.user.id].to_i + 1
end
- puts ":reply_message calculate Completed. users count: #{users.count}"
+ puts ":reply_message calculate Completed. collaboration users count: #{users.count}"
# 对帖子的回复
Message.includes(:author).where("parent_id IS NOT NULL").each do |m|
users[m.author.id] = users[m.author.id].to_i + 1
end
- puts ":reply_posting calculate Completed. users count: #{users.count}"
+ puts ":reply_posting calculate Completed. collaboration users count: #{users.count}"
users.each do |user_id, score|
UserScore.find_or_create_by_user_id(user_id).update_attribute(:collaboration, score)
end
- puts "=== UserScore#collaboration calculate Completed. users count: #{users.count}"
+ puts "=== UserScore#collaboration calculate Completed. collaboration users count: #{users.count}"
users.clear
# influence 影响力得分
- # ...
+ #关注
+ users_influence = {}
+ Watcher.includes(:watchable).where("watchable_type = 'Principal'").all.each do |w|
+ users_influence[w.watchable.id] = users_influence[w.watchable.id].to_i + 2
+ end
+ puts ":followed_by calculate Completed. influence users count: #{users_influence.count}"
+ users_influence.each do |user_id, score|
+ UserScore.find_or_create_by_user_id(user_id).update_attribute(:influence, score)
+ end
+ puts "=== UserScore#influence calculate Completed. influence users count: #{users_influence.count}"
# skill 技术得分
- # ...
+ # 顶踩帖
+ users_skill = {}
+ PraiseTread.where("praise_tread_object_type = 'Memo' || praise_tread_object_type = 'Message'").all.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 = pt.user.get_level
+ if pt.praise_or_tread == 0
+ #踩帖
+ users_skill[pt.user.id] = users_skill[pt.user.id].to_i - 2 #踩别人帖-2分
+ if level == 1
+ users_skill[target_user.id] = users_skill[target_user.id].to_i - 2 #帖子被一级会员踩-2分 add praise_tread
+ elsif level == 2
+ users_skill[target_user.id] = users_skill[target_user.id].to_i - 4 #帖子被二级会员踩-4分 add praise_tread
+ elsif level == 3
+ users_skill[target_user.id] = users_skill[target_user.id].to_i - 6 #帖子被三级会员踩-6分 add praise_tread
+ end
+ elsif pt.praise_or_tread == 1
+ #顶贴
+ if level == 1
+ users_skill[target_user.id] = users_skill[target_user.id].to_i + 4 #帖子被一级会员顶+4分 add praise_tread
+ elsif level == 2
+ users_skill[target_user.id] = users_skill[target_user.id].to_i + 6 #帖子被二级会员顶+6分 add praise_tread
+ elsif level == 3
+ users_skill[target_user.id] = users_skill[target_user.id].to_i + 8 #帖子被三级会员顶+8分 add praise_tread
+ end
+ end
+ end
+ puts ":praised_by_user and :treaded_by_user calculate Completed. skill users count: #{users_skill.count}"
+ users_skill.each do |user_id, score|
+ UserScore.find_or_create_by_user_id(user_id).update_attribute(:skill, score)
+ end
+ puts "=== UserScore#skill calculate Completed. skill users count: #{users_skill.count}"
# active 项目贡献得分
- # ...
+ users_active = {}
+ # 提交代码
+ Changeset.includes(:user).all.each do |changeset|
+ if changeset.user.nil?
+ next
+ end
+ users_active[changeset.user.id] = users_active[changeset.user.id].to_i + 4
+ end
+ puts ":push_code calculate Completed. active users count: #{users_active.count}"
+ #提交文档
+ Document.includes(:user).all.each do |document|
+ if document.user.nil?
+ next
+ end
+ users_active[document.user.id] = users_active[document.user.id].to_i + 4
+ end
+ puts ":push_document calculate Completed. active users count: #{users_active.count}"
+ #提交附件
+ Attachment.includes(:author).all.each do |attachment|
+ #if attachment.container_id_changed?
+ # type = attachment.container_type
+ # types = %w|Document News Version Project Issue Message WikiPage|
+ # if types.include?(type)
+ if attachment.author.nil?
+ next
+ end
+ users_active[attachment.author.id] = users_active[attachment.author.id].to_i + 4
+ # end
+ #end
+ end
+ puts ":push_file calculate Completed. active users count: #{users_active.count}"
+ #更新完成度
+ Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'done_ratio'").each do |j|
+ users_active[j.user.id] = users_active[j.user.id].to_i + 2
+ end
+ puts ":update_issue_ratio calculate Completed. active users count: #{users_active.count}"
+ #发布缺陷
+ Issue.includes(:author).all.each do |issue|
+ users_active[issue.author.id] = users_active[issue.author.id].to_i + 4
+ end
+ puts ":post_issue calculate Completed. active users count: #{users_active.count}"
+
+ users_active.each do |user_id, score|
+ UserScore.find_or_create_by_user_id(user_id).update_attribute(:active, score)
+ end
+ puts "=== UserScore#active calculate Completed. active users count: #{users_active.count}"
+
end
end
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 57a9ea013..1952334e2 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -1449,7 +1449,7 @@ div.square {
overflow: hidden;
width: .6em; height: .6em;
}
-.contextual {float:right; white-space: nowrap; line-height:1.4em;/*margin-top:5px;*/ padding-left: 10px; font-size:0.9em;}
+.contextual {float:right; white-space: nowrap; line-height:1.4em;/*margin-top:5px;*/ padding-left: 10px;padding-right: 10px;padding-top: 5px; font-size:0.9em;}
.contextual input, .contextual select {font-size:0.9em;}
.message .contextual { margin-top: 0; }