Skip to content

Commit 58b7ded

Browse files
committed
disable some admin/report pages that cause slow queries
1 parent f8ff9b8 commit 58b7ded

File tree

2 files changed

+40
-10
lines changed

2 files changed

+40
-10
lines changed

dashboard/app/controllers/reports_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ class ReportsController < ApplicationController
1010
before_action :set_script
1111
include LevelSourceHintsHelper
1212

13+
before_action except: [:user_stats, :header_stats, :students, :prizes, :assume_identity, :assume_identity_form] do
14+
render status: :forbidden, text: "Disabled during HOC because it's too slow"
15+
return false
16+
end
17+
1318
def user_stats
1419
@user = User.find(params[:user_id])
1520
authorize! :read, @user

dashboard/test/controllers/reports_controller_test.rb

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ class ReportsControllerTest < ActionController::TestCase
152152

153153
test "should get usage" do
154154
get :usage, :user_id => @not_admin.id
155-
assert_response :success
155+
assert_response :forbidden # disabled for hoc
156+
#assert_response :success
156157
end
157158

158159
test "should not get usage if not signed in" do
@@ -166,17 +167,18 @@ class ReportsControllerTest < ActionController::TestCase
166167
sign_in @not_admin
167168

168169
get :usage, :user_id => @not_admin.id
169-
170-
assert_response :success
170+
assert_response :forbidden # disabled for hoc
171+
#assert_response :success
171172
end
172173

173174

174175
test "should get usage for students if teacher" do
175176
sign_in @teacher
176177

177178
get :usage, :user_id => @student.id
179+
assert_response :forbidden # disabled for hoc
178180

179-
assert_response :success
181+
#assert_response :success
180182
end
181183

182184
test "should not get usage for other users if not admin or teacher" do
@@ -216,11 +218,30 @@ class ReportsControllerTest < ActionController::TestCase
216218
assert_redirected_to_sign_in
217219
end
218220

219-
generate_admin_only_tests_for :all_usage
221+
def self.generate_admin_forbidden_tests_for(action, params = {})
222+
test "should get #{action}" do
223+
get action, params
224+
assert_response :forbidden
225+
end
220226

221-
generate_admin_only_tests_for :admin_stats
227+
test "should not get #{action} if not signed in" do
228+
sign_out @admin
229+
get action, params
230+
assert_redirected_to_sign_in
231+
end
222232

223-
generate_admin_only_tests_for :admin_gallery
233+
test "should not get #{action} if not admin" do
234+
sign_in @not_admin
235+
get action, params
236+
assert_response :forbidden
237+
end
238+
end
239+
240+
generate_admin_forbidden_tests_for :all_usage # disabled for hoc
241+
242+
generate_admin_forbidden_tests_for :admin_stats # disabled for hoc
243+
244+
generate_admin_forbidden_tests_for :admin_gallery # disabled for hoc
224245

225246
test "admin_gallery shows most recent 25 gallery items" do
226247
sign_in @admin
@@ -230,8 +251,9 @@ class ReportsControllerTest < ActionController::TestCase
230251
end
231252

232253
get :admin_gallery
254+
assert_response :forbidden # disabled for hoc
233255

234-
assert_equal 25, assigns(:gallery_activities).count
256+
# assert_equal 25, assigns(:gallery_activities).count
235257
end
236258

237259
test "students should redirect to new teacher dashboard" do
@@ -241,7 +263,9 @@ class ReportsControllerTest < ActionController::TestCase
241263

242264
test "should get level_stats" do
243265
get :level_stats, {:level_id => create(:level).id}
244-
assert_response :success
266+
267+
assert_response :forbidden # disabled for hoc
268+
# assert_response :success
245269
end
246270

247271
test "should not get level_stats if not admin" do
@@ -325,7 +349,8 @@ class ReportsControllerTest < ActionController::TestCase
325349

326350
test 'should get admin progress' do
327351
get :admin_progress
328-
assert_select 'h1', 'Admin progress'
352+
assert_response :forbidden # disabled for hoc
353+
# assert_select 'h1', 'Admin progress'
329354
end
330355

331356
end

0 commit comments

Comments
 (0)