精品项目,精品课程按照动态数排序

hjq_beidou
huang 9 years ago
parent 3af115ee54
commit 5ec9e31626

@ -89,14 +89,14 @@ class OrganizationsController < ApplicationController
@course_acts = get_course_activities_org @organization, course_ids @course_acts = get_course_activities_org @organization, course_ids
# 精品课程, 不符合条件的组织则不查询 # 精品课程, 不符合条件的组织则不查询
if @organization.org_subfields.where(:field_type => "Compcou", :hide => 0).count > 0 if @organization.org_subfields.where(:field_type => "Compcou", :hide => 0).count > 0
@excellent_courses = Course.where(:is_public => true, :is_delete => false, :is_excellent => true) @excellent_courses = Course.find_by_sql("select c.*, (select count(*) from course_activities where course_activities.course_id = c.id) as course_count
from courses c where c.is_delete =0 and c.is_public =1 and is_excellent =1 order by course_count desc limit 5;")
end end
# 热门项目 # 热门项目
if @organization.org_subfields.where(:field_type => "Comppro", :hide => 0).count > 0 if @organization.org_subfields.where(:field_type => "Comppro", :hide => 0).count > 0
# @excellent_projects = Project.where(:is_public => true, :status => true, :hot => true).order("project_score") # @excellent_projects = Project.where(:is_public => true, :status => true, :hot => true).order("project_score")
@excellent_projects = Project.find_by_sql("SELECT p.* FROM `projects` p, project_scores ps where p.id = ps.project_id and p.is_public =1 and @excellent_projects = Project.find_by_sql("select p.*, (select count(*) from forge_activities where forge_activities.project_id = p.id) as project_count
status =1 and hot =1 order by (ps.issue_num * 4 + ps.issue_journal_num + ps.changeset_num * 4 + ps.board_num * 2 + from projects p where p.status =1 and p.is_public =1 and hot =1 order by project_count desc limit 5;")
ps.board_message_num + ps.news_num + ps.attach_num * 5) desc limit 5;")
end end
# 最新动态, 来自我关联的项目和课程 # 最新动态, 来自我关联的项目和课程
if @organization.org_subfields.where(:field_type => "Compact", :hide => 0).count > 0 if @organization.org_subfields.where(:field_type => "Compact", :hide => 0).count > 0
@ -236,9 +236,11 @@ class OrganizationsController < ApplicationController
@field = params[:org_subfield_id].nil? ? OrgSubfield.where("organization_id =? and field_type =?", params[:id].to_i, "Comppro").first : OrgSubfield.find(params[:org_subfield_id]) @field = params[:org_subfield_id].nil? ? OrgSubfield.where("organization_id =? and field_type =?", params[:id].to_i, "Comppro").first : OrgSubfield.find(params[:org_subfield_id])
@type = params[:type] @type = params[:type]
if @type.nil? if @type.nil?
@containers = Project.find_by_sql("SELECT * FROM `projects` where status = 1 and is_public = 1 and name like '%#{q}%' order by updated_on desc;") @containers = Project.find_by_sql("select p.*, (select count(*) from forge_activities where forge_activities.project_id = p.id) as project_count
from projects p where p.status =1 and p.is_public =1 and name like '%#{q}%' order by project_count desc;")
elsif @type == "famous" elsif @type == "famous"
@containers = Project.find_by_sql("SELECT * FROM `projects` where status =1 and is_public = 1 and hot = 1 and name like '%#{q}%' order by updated_on desc;") @containers = Project.find_by_sql("select p.*, (select count(*) from forge_activities where forge_activities.project_id = p.id) as project_count
from projects p where p.status =1 and p.is_public =1 and hot =1 and name like '%#{q}%' order by project_count desc;")
end end
atta_page_public @containers atta_page_public @containers
end end
@ -248,9 +250,11 @@ class OrganizationsController < ApplicationController
@field = params[:org_subfield_id].nil? ? OrgSubfield.where("organization_id =? and field_type =?", params[:id].to_i, "Compstu").first : OrgSubfield.find(params[:org_subfield_id]) @field = params[:org_subfield_id].nil? ? OrgSubfield.where("organization_id =? and field_type =?", params[:id].to_i, "Compstu").first : OrgSubfield.find(params[:org_subfield_id])
@type = params[:type] @type = params[:type]
if @type.nil? if @type.nil?
@containers = Course.find_by_sql("SELECT * FROM `courses` where is_delete = 0 and is_public = 1 and name like '%#{q}%' order by updated_at desc;") @containers = Course.find_by_sql("select c.*, (select count(*) from course_activities where course_activities.course_id = c.id) as course_count
from courses c where c.is_delete =0 and c.is_public =1 and name like '%#{q}%' order by course_count desc;")
elsif @type == "famous" elsif @type == "famous"
@containers = Course.find_by_sql("SELECT * FROM `courses` where is_delete = 0 and is_public = 1 and is_excellent = 1 and name like '%#{q}%' order by updated_at desc;") @containers = Course.find_by_sql("select c.*, (select count(*) from course_activities where course_activities.course_id = c.id) as course_count
from courses c where c.is_delete =0 and c.is_public =1 and is_excellent = 1 and name like '%#{q}%' order by course_count desc;")
end end
atta_page_public @containers atta_page_public @containers
end end

Loading…
Cancel
Save