Extract inline query to an OfficerAssignment scope
This commit is contained in:
@@ -19,7 +19,7 @@ class Admin::Poll::OfficerAssignmentsController < Admin::Poll::BaseController
|
||||
@officer_assignments = ::Poll::OfficerAssignment.
|
||||
joins(:booth_assignment).
|
||||
includes(:recounts, booth_assignment: :booth).
|
||||
where("officer_id = ? AND poll_booth_assignments.poll_id = ?", @officer.id, @poll.id).
|
||||
by_officer_and_poll(@officer.id, @poll.id).
|
||||
order(:date)
|
||||
end
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@ class Poll
|
||||
|
||||
scope :voting_days, -> { where(final: false) }
|
||||
scope :final, -> { where(final: true) }
|
||||
scope :by_officer_and_poll, ->(officer_id, poll_id) do
|
||||
where("officer_id = ? AND poll_booth_assignments.poll_id = ?", officer_id, poll_id)
|
||||
end
|
||||
|
||||
before_create :log_user_data
|
||||
|
||||
|
||||
Reference in New Issue
Block a user