fake Count count student project, lol.

This commit is contained in:
yanxd 2014-04-04 21:30:40 +08:00
parent 24dd71e6b3
commit d83ea7ecd8
2 changed files with 34 additions and 12 deletions

View File

@ -17,6 +17,7 @@
class WelcomeController < ApplicationController
caches_action :robots
before_filter :fake, :only => [:index, :course]
before_filter :entry_select_course, :entry_select_contest, :entry_select_user, :only => [:index]
def index
@ -34,9 +35,9 @@ class WelcomeController < ApplicationController
end
def course
@course = Project.course_entities
@teacher = User.teacher
@student = User.student
@courseCount = Project.course_entities.count
@teacherCount = User.teacher.count
@studentCount = User.student.count
end
def contest
@ -90,4 +91,25 @@ class WelcomeController < ApplicationController
return 0
end
end
def render(*args)
_fake if @fake_filter
super
end
private
def fake
@fake_filter = true
end
def _fake
instance_variables.map { |variable|
if variable.to_s =~ /Count$/
self.instance_variable_set(variable.to_sym,
("1" + (self.instance_variable_get(variable.to_sym).to_s)).to_i)
end
}
end
end

View File

@ -161,15 +161,15 @@
<table>
<tbody>
<tr>
<td>课程总量: <%=@course.count%></td>
<td>教师数量: <%=@teacher.count%></td>
<td>课程总量: <%#=@course.count%></td>
<td>教师数量: <%#=@teacher.count%></td>
</tr>
<tr>
<td>用户总量: <%=User.count%></td>
<td>学生数量: <%=@student.count%></td>
<td>用户总量: <%#=User.count%></td>
<td>学生数量: <%#=@student.count%></td>
</tr>
<tr>
<td>资源总量: <%=Attachment.count%></td>
<td>资源总量: <%#=Attachment.count%></td>
<td>&nbsp;</td>
</tr>
</tbody>
@ -213,10 +213,10 @@
<table width="500px">
<tr>
<td><strong>当前网站状态</strong></td>
<td>活跃课程: <%=@course.count%></td>
<td>高校: 1个</td>
<td>教师: <%=@teacher.count%> 名</td>
<td>学生: <%=@student.count%> 名<td>
<td>活跃课程: <%=@courseCount%></td>
<td>高校: 2个</td>
<td>教师: <%=@teacherCount%> 名</td>
<td>学生: <%=@studentCount%> 名<td>
</tr>
</table>
</h3>