Skip to content

Commit

Permalink
Merge pull request #2603 from pat-son/datasetOptimization
Browse files Browse the repository at this point in the history
Optimized fetching of data sets
  • Loading branch information
pat-son authored Feb 24, 2017
2 parents 9d45bee + 0329ea8 commit 4c04be4
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions app/controllers/visualizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,21 +250,14 @@ def displayVis
# build list of datasets
if !params[:datasets].nil?
dsets = params[:datasets].split(',')
dsets.each do |id|
begin
dset = DataSet.find_by_id(id)
if dset.project_id == @project.id
@datasets.push dset
else
fail 'data set does not belong to project'
end
rescue
respond_to do |format|
format.html { redirect_to '/404.html' }
format.json { render json: { errors: ['File not found.'] }, status: 404 }
end
return
@datasets = DataSet.where(id: dsets, project_id: @project.id)

if @datasets.length == 0
respond_to do |format|
format.html { redirect_to '/404.html' }
format.json { render json: { errors: ['File not found.'] }, status: 404 }
end
return
end
else
@datasets = DataSet.includes(:user, :media_objects).where(project_id: params[:id])
Expand Down

0 comments on commit 4c04be4

Please sign in to comment.