fix ePortfolio page performance / page timeouts

fixes OUT-2961

test plan:
- have at least 2 student in a course
- submit to several of the assignments in the course
- go to the students ePortfolio and confirm their submissions
  appear on the "Welcome to Your ePortfolio" page
- make the ePortfolio public under 'ePortfolio' settings
- view the ePortfolio as another student, confirm that no
  "Recent Submissions" list appears for the public portfolio
   (only should appear when logged in as the user who owns the
   portfolio)

Change-Id: I651db17382e151b44fd2b2d59a2ac5f26f28451f
Reviewed-on: https://gerrit.instructure.com/179302
Tested-by: Jenkins
Reviewed-by: Augusto Callejas <acallejas@instructure.com>
QA-Review: Brian Watson <bwatson@instructure.com>
Product-Review: Neil Gupta <ngupta@instructure.com>
This commit is contained in:
Matthew Berns 2019-01-24 16:42:24 -06:00
parent 4a0ce4f325
commit 8a71527884
3 changed files with 4 additions and 3 deletions

View File

@ -129,7 +129,7 @@
<div style="margin: 5px 20px;"><%= t(:no_submissions, "No Submissions Found") %></div>
<% end %>
<ul class="submission_list" id="recent_submissions" style="max-height: 200px; overflow: auto;">
<% @portfolio.user.submissions.in_workflow_state(['submitted', 'graded']).each do |submission| %>
<% @recent_submissions.each do |submission| %>
<% next unless submission.assignment.published? && submission.context.published? %>
<% already_used = (@used_submission_ids.include?(submission.id) rescue false) %>
<li class="clearfix submission <%= 'already_used' if already_used %>" title="<%= t('titles.already_used', "This submission is already included in your portfolio") if already_used %>" id="recent_submission_<%= submission.id %>" tabindex="0">

View File

@ -20,7 +20,8 @@ module EportfolioPage
def eportfolio_page_attributes
@categories = @portfolio.eportfolio_categories
if @portfolio.grants_right?(@current_user, session, :manage)
@recent_submissions = @current_user.submissions.order("created_at DESC").to_a if @current_user && @current_user == @portfolio.user
@recent_submissions = @current_user.submissions.in_workflow_state(['submitted', 'graded']).
order("created_at DESC").to_a if @current_user && @current_user == @portfolio.user
@files = @current_user.attachments.to_a
@folders = @current_user.active_folders.preload(:active_sub_folders, :active_file_attachments).to_a
end

View File

@ -25,7 +25,7 @@ describe "/eportfolios/show" do
view_portfolio
category = assign(:category, @portfolio.eportfolio_categories.create!(:name => "some category"))
assign(:categories, [category])
assign(:recent_submissions, [])
assign(:recent_submissions, @portfolio.user.submissions.in_workflow_state(['submitted', 'graded']))
assign(:folders, [])
assign(:files, [])
assign(:page, @portfolio.eportfolio_entries.create!(:name => "some entry", :eportfolio_category => category))