Skip to content

Commit f0eefb6

Browse files
authored
Merge pull request #584 from testmycode/optimizations-3232
Optimizations
2 parents 86536c3 + deb0140 commit f0eefb6

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

app/controllers/exercises_controller.rb

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ def show
1919

2020
@submissions = @submissions.where(user_id: current_user.id) unless can? :teach, @course
2121
@submissions = @submissions.includes(:awarded_points).includes(:user).includes(:course)
22-
@submission_count = @submissions.count
2322
@submissions = @submissions.limit(50) unless !!params[:view_all]
2423
else
2524
@submissions = nil

app/controllers/organizations_controller.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,18 @@ def index
1111
ordering = Arel.sql('hidden, LOWER(name)')
1212
@organizations = Organization
1313
.accepted_organizations
14+
.with_attached_logo
1415
.order(ordering)
1516
.reject { |org| org.hidden? && !can?(:view_hidden_organizations, nil) || !org.visibility_allowed?(request, current_user) }
16-
@my_organizations = Organization.taught_organizations(current_user).select { |org| org.visibility_allowed?(request, current_user) }
17-
@my_organizations |= Organization.assisted_organizations(current_user).select { |org| org.visibility_allowed?(request, current_user) }
18-
@my_organizations |= Organization.participated_organizations(current_user).select { |org| org.visibility_allowed?(request, current_user) }
17+
@my_organizations = Organization.taught_organizations(current_user).with_attached_logo.select { |org| org.visibility_allowed?(request, current_user) }
18+
@my_organizations |= Organization.assisted_organizations(current_user).with_attached_logo.select { |org| org.visibility_allowed?(request, current_user) }
19+
@my_organizations |= Organization.participated_organizations(current_user).with_attached_logo.select { |org| org.visibility_allowed?(request, current_user) }
1920
@my_organizations.natsort_by!(&:name)
2021
@courses_under_initial_refresh = Course.where(initial_refresh_ready: false)
2122
@pinned_organizations = Organization
2223
.accepted_organizations
2324
.where(pinned: true)
25+
.with_attached_logo
2426
.order(ordering)
2527
.select { |org| org.visibility_allowed?(request, current_user) }
2628
.reject { |org| org.hidden? && !can?(:view_hidden_organizations, nil) }

app/views/exercises/show.html.erb

+2-2
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@
180180
<div class="col-md-12">
181181
<h2>Submissions</h2>
182182
<% if !@submissions.empty? %>
183-
<% if @submissions.size < @submission_count %>
184-
<p>Showing <%= @submissions.size%> of <%= @submission_count %> submissions. <%= link_to "View all submissions", exercise_path(@exercise, view_all: 1) %></p>
183+
<% if @submissions.size == 50 %>
184+
<p>Showing only 50 submissions. <%= link_to "View all submissions", exercise_path(@exercise, view_all: 1) %></p>
185185
<% end %>
186186
<%= show_submission_list(@submissions, :show_exercise_column => false, :show_awarded_points => true) %>
187187
<% else %>

0 commit comments

Comments
 (0)