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.
|
@officer_assignments = ::Poll::OfficerAssignment.
|
||||||
joins(:booth_assignment).
|
joins(:booth_assignment).
|
||||||
includes(:recounts, booth_assignment: :booth).
|
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)
|
order(:date)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ class Poll
|
|||||||
|
|
||||||
scope :voting_days, -> { where(final: false) }
|
scope :voting_days, -> { where(final: false) }
|
||||||
scope :final, -> { where(final: true) }
|
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
|
before_create :log_user_data
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user