名师榜sql查询
This commit is contained in:
parent
5880a12290
commit
99d9a28828
|
@ -103,7 +103,7 @@ class OrganizationsController < ApplicationController
|
|||
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
|
||||
if @org_subfield.field_type == "Comptec" || @org_subfield.field_type == "Compstu"
|
||||
#@org_students = User.find_by_sql("SELECT * FROM users u, user_extensions ue where u.id = ue.user_id and ue.identity =1;")
|
||||
@org_teachers = User.find_by_sql("SELECT * FROM users u, user_extensions ue where u.id = ue.user_id and ue.identity =0;")
|
||||
@org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 order by course_count desc")
|
||||
else
|
||||
@org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0
|
||||
@org_activities = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10)
|
||||
|
|
|
@ -170,7 +170,11 @@ module OrganizationsHelper
|
|||
end
|
||||
|
||||
def org_teacher_resource_count user
|
||||
results = Attachment.find_by_sql("SELECT * FROM `attachments` where author_id = #{user.user_id};")
|
||||
results = Attachment.find_by_sql("SELECT count(*) FROM attachments where author_id = #{user.id};").count
|
||||
end
|
||||
|
||||
def org_teacher_course_count user
|
||||
results = Course.find_by_sql("select count(*) from courses where courses.tea_id = #{user.id}").count
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -5,4 +5,5 @@ class School < ActiveRecord::Base
|
|||
def to_s
|
||||
self.name.to_s
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<span class="f12 fontGrey2"><%= org_teacher.technical_title %></span></div>
|
||||
<% end %>
|
||||
<div class="teacher-social-block">
|
||||
<div class="block-num"><%= User.current.courses.count %></div>
|
||||
<div class="block-num"><%= org_teacher.courses.count %></div>
|
||||
<div class="block-title">课程数</div>
|
||||
</div>
|
||||
<div class="block-slice"></div>
|
||||
|
@ -33,7 +33,7 @@
|
|||
</div>
|
||||
<div class="block-slice"></div>
|
||||
<div class="teacher-social-block">
|
||||
<div class="block-num"><%= org_teacher_resource_count(org_teacher) %>8000</div>
|
||||
<div class="block-num"><%= org_teacher_resource_count(org_teacher) %></div>
|
||||
<div class="block-title">资源数</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue