diff --git a/Gemfile b/Gemfile index 58ccbc011..b8b49cf95 100644 --- a/Gemfile +++ b/Gemfile @@ -50,10 +50,10 @@ gem 'elasticsearch-model' gem 'elasticsearch-rails' #rails 3.2.22.2 bug - gem "test-unit", "~>3.0" +# gem "test-unit", "~>3.0" ### profile - gem 'oneapm_rpm' +# gem 'oneapm_rpm' group :development do gem 'grape-swagger' diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index da7cfd849..1ffc4f0d7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -433,7 +433,7 @@ class UsersController < ApplicationController render_404 return end - @message_alls = paginateHelper @message_alls,25 + @message_alls = paginateHelper @message_alls, 25 respond_to do |format| format.html{render :layout=>'new_base_user'} end @@ -1822,6 +1822,16 @@ class UsersController < ApplicationController principal_types = "JournalsForMessage" container_type = '' act_type = '' + + # 用户项目数 + @my_project_count = user_project_count + # 用户的课程数 + @my_course_count = user_course_count + # 用户发布的issue数 + @issues_author_is_self_count = issues_author_is_self_count + # 用户收到的issue数 + @issues_assigned_is_self_count = issues_assigned_is_self_count + if params[:type].present? case params[:type] when "course_homework" diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 98024954d..e5dcfc2df 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -53,6 +53,43 @@ module UsersHelper end + + # 用户项目总数 + def user_project_count + @my_projects = @user.projects.where("projects.user_id = #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updatetime").order("updatetime DESC") + @my_projects_count = @my_projects.count + @my_joined_projects = @user.projects.where("projects.user_id != #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updatetime").order("updatetime DESC") + @my_joined_projects_count = @my_joined_projects.count + + @my_project_total = @my_projects_count + @my_joined_projects_count + end + + # 用户的课程总数 + def user_course_count + @my_course_count = @user.syllabuses.count + + sy_courses = @user.courses.visible.not_deleted + syllabus_ids = sy_courses.empty? ? '(-1)' : "(" + sy_courses.map{|course| !course.syllabus_id.nil? && course.syllabus_id}.join(",") + ")" + syllabus_members = SyllabusMember.where("user_id = #{@user.id}") + syllabus_member_ids = syllabus_members.empty? ? "(-1)" : "(" + syllabus_members.map{|syl_mem| syl_mem.syllabus_id}.join(',') + ")" + @join_syllabuses = Syllabus.where("(id in #{syllabus_ids} or id in #{syllabus_member_ids}) and user_id != #{@user.id}") + @my_joined_course_count = @join_syllabuses.count + + @user_course_total = @my_joined_course_count + @my_course_count + end + + # 用户发布的issue数 + def issues_author_is_self_count + @issues = Issue.where( :author_id => @user.id ) + @issues_author_is_self_count = @issues.count + end + + # 用户收到的issue数 + def issues_assigned_is_self_count + @issues = Issue.where( :assigned_to_id => @user.id ) + @issues_assigned_is_self_count = @issues.count + end + def get_resource_type type case type when 'Course' diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index db1e4f1cc..971414835 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -7,13 +7,19 @@ + + <% if hidden_unproject_infos %> - + <% memo = Memo.where(:id => 1168).first %> <% unless memo.nil? %> <% end %>
  • - <%= link_to "我的组织", user_organizations_user_path(:id => User.current), :class => "menuGrey"%> + <%= link_to '我的项目', {:controller => "users", :action => "user_projectlist", :id => @user}, :id => 'user_project_list', :class => "menuGrey" %>
  • - <%= link_to "新建组织", new_organization_path, :class => "menuGrey"%> + <%= link_to "我的组织", user_organizations_user_path(:id => User.current), :class => "menuGrey"%>
  • diff --git a/app/views/layouts/_user_brief_introduction.html.erb b/app/views/layouts/_user_brief_introduction.html.erb index fac5177a3..233d6115b 100644 --- a/app/views/layouts/_user_brief_introduction.html.erb +++ b/app/views/layouts/_user_brief_introduction.html.erb @@ -1,10 +1,10 @@ - <% if user.user_extensions && user.user_extensions.brief_introduction && !user.user_extensions.brief_introduction.empty? %> - <%= user.user_extensions.brief_introduction %> - <% else%> - 这个小伙伴很懒,什么都没留下~ + -<% if User.current == user%> - <%= link_to image_tag("../images/signature_edit.png",width:"12px", height: "12px"), "javascript:void(0);", :onclick => "show_edit_user_introduction();"%> -<% end %> +<%# if User.current == user%> + <%#= link_to image_tag("../images/signature_edit.png",width:"12px", height: "12px"), "javascript:void(0);", :onclick => "show_edit_user_introduction();"%> +<%# end %> diff --git a/app/views/layouts/_user_watch_btn.html.erb b/app/views/layouts/_user_watch_btn.html.erb index 0e0ae1e1f..cf580f920 100644 --- a/app/views/layouts/_user_watch_btn.html.erb +++ b/app/views/layouts/_user_watch_btn.html.erb @@ -1,8 +1,8 @@