Skip to content

Commit

Permalink
Replace date_released with date_end and include references in hold he…
Browse files Browse the repository at this point in the history
…lper methods
  • Loading branch information
jazairi committed Mar 3, 2022
1 parent 8a63045 commit 29ee59c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/controllers/report_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def holds_by_source
term = params[:graduation] ? params[:graduation].to_s : 'all'
@this_term = 'all terms'
@this_term = term.in_time_zone('Eastern Time (US & Canada)').strftime('%b %Y') if term != 'all'
holds = Hold.all.includes(:versions).includes(:thesis).includes(thesis: :users).includes(thesis: :authors)
holds = Hold.all.includes(:thesis).includes(:hold_source).includes(thesis: :users).includes(thesis: :authors)
@terms = Report.new.extract_terms holds
@hold_sources = HoldSource.pluck(:source).uniq.sort
term_filtered = filter_holds_by_term holds
Expand Down
6 changes: 2 additions & 4 deletions app/helpers/hold_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ def render_hold_history_field(field_name, field_value)

def filter_holds_by_term(holds)
if params[:graduation] && params[:graduation] != 'all'
return holds.where('theses.grad_date = ?',
params[:graduation])
return holds.where('theses.grad_date = ?', params[:graduation]).references(:thesis)
end

holds
end

def filter_holds_by_source(holds)
if params[:hold_source] && params[:hold_source] != 'all'
return holds.where('hold_sources.source = ?',
params[:hold_source])
return holds.where('hold_sources.source = ?', params[:hold_source]).references(:thesis)
end

holds
Expand Down
2 changes: 1 addition & 1 deletion app/models/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def extract_terms(collection)
if collection.first.is_a? Thesis
collection.pluck(:grad_date).uniq.sort
else
collection.joins(:thesis).pluck(:grad_date).uniq.sort
collection.includes(:thesis).pluck(:grad_date).uniq.sort
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/report/_hold.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<td><%= hold.hold_source.source %></td>
<td><%= hold.status %></td>
<td><%= hold.date_requested %></td>
<td><%= hold.date_start %></td>
<td><%= hold.date_end %></td>
<td><%= hold.date_released %></td>
</tr>
2 changes: 1 addition & 1 deletion app/views/report/holds_by_source.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<th scope="col">Hold source</th>
<th scope="col">Status</th>
<th scope="col">Date requested</th>
<th scope="col">Start date</th>
<th scope="col">End date</th>
<th scope="col">Date released</th>
</tr>
</thead>
<tbody>
Expand Down

0 comments on commit 29ee59c

Please sign in to comment.