From d2b5560d5ea45c9608f29b76cfbf764addbedc68 Mon Sep 17 00:00:00 2001 From: yanxd Date: Mon, 16 Jun 2014 10:54:52 +0800 Subject: [PATCH 1/3] =?UTF-8?q?userscore=20=E4=BA=8B=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/userscore.rake | 80 +++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 33 deletions(-) diff --git a/lib/tasks/userscore.rake b/lib/tasks/userscore.rake index 144b9c9b9..9bc54f2c6 100644 --- a/lib/tasks/userscore.rake +++ b/lib/tasks/userscore.rake @@ -4,9 +4,10 @@ task :user_score do end namespace :user_score do - desc "calculating user score" - # Rails.env = 'production' - task :calculate => :environment do + desc "calculating user score" + task :calculate => :environment do + puts "truncating table...#{Rails.env}" + UserScore.destroy_all puts "loading..." # collaboration 协同得分 users = {} @@ -40,10 +41,13 @@ namespace :user_score do end 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) + UserScore.transaction do + users.each do |user_id, score| + UserScore.find_or_create_by_user_id(user_id).update_attribute(:collaboration, score) + end end puts "=== UserScore#collaboration calculate Completed. collaboration users count: #{users.count}" + puts "" users.clear @@ -55,23 +59,26 @@ namespace :user_score do 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) + UserScore.transaction do + users_influence.each do |user_id, score| + UserScore.find_or_create_by_user_id(user_id).update_attribute(:influence, score) + end end puts "=== UserScore#influence calculate Completed. influence users count: #{users_influence.count}" + puts "" # 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 + 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分 + #踩帖 + 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 @@ -80,7 +87,7 @@ namespace :user_score do 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 @@ -91,11 +98,14 @@ namespace :user_score do end end puts ":praised_by_user and :treaded_by_user calculate Completed. skill users count: #{users_skill.count}" + UserScore.transaction do 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}" - + end + puts "=== UserScore#skill calculate Completed. skill users count: #{users_skill.count}" + puts "" + # active 项目贡献得分 users_active = {} # 提交代码 @@ -115,20 +125,20 @@ namespace :user_score do 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}" - #更新完成度 + 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 @@ -139,10 +149,14 @@ namespace :user_score do 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) + + UserScore.transaction do + users_active.each do |user_id, score| + UserScore.find_or_create_by_user_id(user_id).update_attribute(:active, score) + end end puts "=== UserScore#active calculate Completed. active users count: #{users_active.count}" + puts "" end end @@ -151,11 +165,11 @@ desc "create tmp file, to test" file 'tmp/test.yml' do require 'yaml' var = { - :name => "name", - :age => "age", - :agent => "agent" + :name => "name", + :age => "age", + :agent => "agent" } File.open('tmp/test.yml', 'w') do |f| - f.write YAML.dump({'conf' => var }) + f.write YAML.dump({'conf' => var}) end end \ No newline at end of file From 99e5644c4efc2134fa99df0f4284309d7b085e19 Mon Sep 17 00:00:00 2001 From: nwb Date: Mon, 16 Jun 2014 17:45:14 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E6=A0=87=E7=AD=BE=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile.lock | 12 ------------ app/views/attachments/upload.js.erb | 2 -- 2 files changed, 14 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index efc236e7e..e6ee7da71 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -74,19 +74,11 @@ GEM mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) - method_source (0.8.2) mime-types (1.23) multi_json (1.7.6) mysql2 (0.3.11-x86-mingw32) net-ldap (0.3.1) polyglot (0.3.3) - pry (0.9.12.6-x86-mingw32) - coderay (~> 1.0) - method_source (~> 0.8) - slop (~> 3.4) - win32console (~> 1.3) - pry-nav (0.2.3) - pry (~> 0.9.10) rack (1.4.5) rack-cache (1.2) rack (>= 0.4) @@ -121,7 +113,6 @@ GEM railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) - slop (3.5.0) sprockets (2.2.2) hike (~> 1.2) multi_json (~> 1.0) @@ -136,7 +127,6 @@ GEM uglifier (1.0.3) execjs (>= 0.3.0) multi_json (>= 1.0.2) - win32console (1.3.2-x86-mingw32) PLATFORMS x86-mingw32 @@ -154,8 +144,6 @@ DEPENDENCIES jquery-rails (~> 2.0.2) mysql2 (~> 0.3.11) net-ldap (~> 0.3.1) - pry - pry-nav rack-mini-profiler! rack-openid rails (= 3.2.13) diff --git a/app/views/attachments/upload.js.erb b/app/views/attachments/upload.js.erb index 63600619b..82b79bb63 100644 --- a/app/views/attachments/upload.js.erb +++ b/app/views/attachments/upload.js.erb @@ -11,6 +11,4 @@ fileSpan.find('a.remove-upload') "href": '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>' }) .off('click'); -var divattach = fileSpan.find('div.div_attachments'); -divattach.html('<%= j(render :partial => 'tags/tagEx', :locals => {:obj => @attachment, :object_flag => "6"})%>'); <% end %> From 099577fb5995aee1ef58c1b509590d09af2c102b Mon Sep 17 00:00:00 2001 From: yanxd Date: Mon, 16 Jun 2014 17:51:51 +0800 Subject: [PATCH 3/3] remove all icon display --- public/stylesheets/application.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 1952334e2..2df42c19a 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -1847,7 +1847,7 @@ a.remove-upload:hover {text-decoration:none !important;} /*gcm upload file count and deleteall*/ #upload_file_count #count {color:red; font-size:1.5em;} -span.add_attachment .remove_all {background:none;background: url(../images/delete.png) no-repeat 1px 50%; width:1px; display:inline-block;position:absolute;right:61px;text-decoration:none;} +span.add_attachment .remove_all {background:none;background: url(../images/delete.png) no-repeat 1px 50%; width:1px; display:inline-block;position:absolute;right:10%;text-decoration:none;} div.fileover { background-color: lavender; }