diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 78e20c2a7..d474b5587 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -9,8 +9,13 @@ module CoursesHelper =end TeacherRoles = [3, 4, 7, 9] StudentRoles = [5, 10] - + AllPeople = StudentRoles+TeacherRoles ## return people count + + # 返回x项目成员数量,即roles表中定义的所有成员 + def projectCount project + searchCountByRoles project, AllPeople + end # 返回教师数量,即roles表中定义的Manager def teacherCount project diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 35314efcc..b9d8ef932 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -285,6 +285,7 @@ module ProjectsHelper SELECT project_id,grade FROM project_statuses WHERE project_type = 0 ORDER BY grade DESC LIMIT #{limit} ) AS t ON p.id = t.project_id ") end + # 判断课程是否结束,快别用,这个定日子的方法有问题 def course_timeout? project diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index ed90dd24f..fd00c83e2 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -39,6 +39,13 @@ module WelcomeHelper end end + def get_project_avatar project + if get_avatar?(project) + url_to_avatar(project) + else + '../images/avatars/Project/project.jpg' + end + end # 前略·天国の首页君/Earth has been unable stop to welcomePage's. # sum - 要搜索的项目数量 # max_rate - 新项目所占所有项目的比重,10分制 @@ -56,10 +63,23 @@ module WelcomeHelper c2 = c2 - c1 (c1.take(max)+c2).take(sum) end - + + def find_miracle_project(sum=10, max_rate=7) + max = sum*(max_rate.to_f/10) + c1 = find_new_project(sum).to_a.dup + c2 = find_all_hot_project(sum).to_a.dup + c2 = c2 - c1 + (c1.take(max)+c2).take(sum) + end + def find_new_course limit=15 Project.visible.joins(:course_extra).where("#{Project.table_name}.project_type = ? ", 1).order("courses.time DESC, #{Project.table_name}.created_on DESC").limit(limit).all end + + def find_new_project limit=15 + Project.visible.joins(:course_extra).where("#{Project.table_name}.project_type = ? ", 0).order("courses.time DESC, #{Project.table_name}.created_on DESC").limit(limit).all + end + def find_all_hot_project limit=15 sort_project_by_hot limit diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index c9fad6757..eae4cba2a 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -105,10 +105,8 @@ <%= stylesheet_link_tag 'welcome' %> - - -