Skip to content

Commit

Permalink
smol bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspermayone committed Aug 4, 2024
1 parent bf89316 commit 2db6d5c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/controllers/loaners_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def show
# Measure the time taken to find and display the loaner
StatsD.measure('loaner.show_request') do
@loaner
@loans = @loaner.loans.order(loaned_at: :desc)
end
end

Expand Down
9 changes: 9 additions & 0 deletions app/models/loan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ def extend
end
end
end

event :return do
transitions from: :out, to: :returned

after do
StatsD.increment("loan.returned")
self.update(returned_at: Time.now)
end
end
end

def log_status_change
Expand Down
4 changes: 2 additions & 2 deletions app/models/loaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def chrome_enable

after do
StatsD.increment("loaner.returned")
self.loan.returned_at = Time.now
self.loan.save!

self.current_loan.return!
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/loaners/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
</tr>
</thead>
<tbody>
<% @loaner.loans.each do |loan| %>
<% @loans.each do |loan| %>
<tr>
<td><%= loan.reason.humanize %></td>
<td><%= loan.borrower.first_name %> <%= loan.borrower.last_name %></td>
Expand Down

0 comments on commit 2db6d5c

Please sign in to comment.