diff --git a/app/models/user.rb b/app/models/user.rb index 674e774d0..b9d752eb6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -82,6 +82,7 @@ class User < Principal #####fq has_many :jours, :class_name => 'JournalsForMessage', :dependent => :destroy + has_many :journals_messages, :class_name => 'JournalsForMessage', :foreign_key => "user_id", :dependent => :destroy has_many :bids, :foreign_key => 'author_id', :dependent => :destroy has_many :journals_for_messages, :as => :jour, :dependent => :destroy has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1" diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index 232103273..2063528cc 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -78,7 +78,7 @@ <% user_changesets_score = user_changesets_count * 0.3 %> <% finall_user_project_score = journals_score + user_changesets_score %> - <% journals_for_messages_count = @user.journals_for_messages.count %> + <% journals_for_messages_count = @user.journals_messages.count %> <% activities_count = @user.activities.count %> <% journals_for_messages_score = journals_for_messages_count * 0.05 %> <% activities_score = activities_count * 0.2 %> diff --git a/app/views/users/_activity_score_index.html.erb b/app/views/users/_activity_score_index.html.erb index fd1947812..fa9aad180 100644 --- a/app/views/users/_activity_score_index.html.erb +++ b/app/views/users/_activity_score_index.html.erb @@ -1,10 +1,10 @@ -<% journals_for_messages_count = @user.journals_for_messages.count %> +<% journals_for_messages_count = @user.journals_messages.count %> <% journals_for_messages_score = journals_for_messages_count * 0.05 %> <% activities_count = @user.activities.count %> <% activities_score = activities_count * 0.2 %> <% finall_activity_score = journals_for_messages_score + activities_score %> -
<%= l(:label_message_number) %> * 0.05 = <%= @user.journals_for_messages.count %> * 0.05 = <%= format("%.2f" , journals_for_messages_score).to_f %>
+
<%= l(:label_message_number) %> * 0.05 = <%= @user.journals_messages.count %> * 0.05 = <%= format("%.2f" , journals_for_messages_score).to_f %>
<%= l(:label_activity_number) %> * 0.2 = <%= @user.activities.count %> * 0.2 = <%= format("%.2f" , activities_score).to_f %>
<%= l(:label_user_score_of_activity) %> = <%= format("%.2f" , journals_for_messages_score).to_f %> + <%= format("%.2f" , activities_score).to_f %> = <%= format("%.2f" , finall_activity_score).to_f %>
diff --git a/app/views/users/_score_index.html.erb b/app/views/users/_score_index.html.erb index 8c2f98541..814e9d9ec 100644 --- a/app/views/users/_score_index.html.erb +++ b/app/views/users/_score_index.html.erb @@ -9,7 +9,7 @@ <% user_changesets_score = user_changesets_count * 0.3 %> <% finall_user_project_score = journals_score + user_changesets_score %> -<% journals_for_messages_count = @user.journals_for_messages.count %> +<% journals_for_messages_count = @user.journals_messages.count %> <% activities_count = @user.activities.count %> <% journals_for_messages_score = journals_for_messages_count * 0.05 %> <% activities_score = activities_count * 0.2 %> diff --git a/app/views/users/_show_score.html.erb b/app/views/users/_show_score.html.erb index 7001f7a94..0297a4e02 100644 --- a/app/views/users/_show_score.html.erb +++ b/app/views/users/_show_score.html.erb @@ -11,7 +11,7 @@ <% user_changesets_score = user_changesets_count * 0.3 %> <% finall_user_project_score = journals_score + user_changesets_score %> -<% journals_for_messages_count = @user.journals_for_messages.count %> +<% journals_for_messages_count = @user.journals_messages.count %> <% activities_count = @user.activities.count %> <% journals_for_messages_score = journals_for_messages_count * 0.05 %> <% activities_score = activities_count * 0.2 %> diff --git a/app/views/users/_user_show.html.erb b/app/views/users/_user_show.html.erb index 71157d070..905265c8b 100644 --- a/app/views/users/_user_show.html.erb +++ b/app/views/users/_user_show.html.erb @@ -13,7 +13,7 @@ <% user_changesets_score = user_changesets_count * 0.3 %> <% finall_user_project_score = journals_score + user_changesets_score %> - <% journals_for_messages_count = user.journals_for_messages.count %> + <% journals_for_messages_count = user.journals_messages.count %> <% activities_count = user.activities.count %> <% journals_for_messages_score = journals_for_messages_count * 0.05 %> <% activities_score = activities_count * 0.2 %> diff --git a/db/migrate/20130828004955_stored_status_procedure.rb b/db/migrate/20130828004955_stored_status_procedure.rb index 884c47bba..248fc488c 100644 --- a/db/migrate/20130828004955_stored_status_procedure.rb +++ b/db/migrate/20130828004955_stored_status_procedure.rb @@ -8,17 +8,15 @@ BEGIN DECLARE user_changesets_count int(10); DECLARE _done tinyint(1) DEFAULT 0; DECLARE cur_user CURSOR FOR - SELECT - user_id, - COUNT(*) - FROM changesets - WHERE user_id != '' - GROUP BY user_id; + SELECT + users.id + FROM users + WHERE users.type = 'User' AND users.status = 1 AND users.admin = 0; DECLARE CONTINUE HANDLER FOR NOT FOUND SET _done = 1; OPEN cur_user; loop_xxx: LOOP - FETCH cur_user INTO user_uid, user_changesets_count; + FETCH cur_user INTO user_uid ; IF _done = 1 THEN LEAVE loop_xxx; END IF; @@ -35,7 +33,7 @@ LOOP SELECT COUNT(*) INTO journals_for_messages_count FROM journals_for_messages - WHERE user_id = user_uid; + WHERE user_id = user_uid ; SELECT COUNT(*) INTO journals_count FROM journals @@ -60,6 +58,12 @@ LOOP COUNT(*) INTO activities_count FROM activities WHERE user_id = user_uid; + SELECT + COUNT(*) INTO user_changesets_count + FROM changesets + WHERE changesets.user_id = user_uid; + + SET total_count = journals_for_messages_count * 0.05 + journals_count * 0.1 + @@ -97,7 +101,7 @@ BEGIN projects.id FROM projects WHERE projects.status <> 9 - AND projects.is_public = 1 ; + AND projects.is_public = 1 AND projects.project_type = 0 ; DECLARE CONTINUE HANDLER FOR NOT FOUND SET _done = 1; OPEN cur_project;