Skip to content

Commit

Permalink
reuse existing query
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulJKim committed Oct 29, 2024
1 parent afdb225 commit 6c50e93
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions lib/screenplay/pa_messages/pa_message/queries.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,7 @@ defmodule Screenplay.PaMessages.PaMessage.Queries do
) ::
Ecto.Query.t()
def active(q \\ PaMessage, alert_ids, now) do
current_service_day_of_week = Util.get_current_service_day(now)

from m in q,
where:
^current_service_day_of_week in m.days_of_week and
m.start_datetime <= ^now and
((is_nil(m.end_datetime) and m.alert_id in ^alert_ids) or m.end_datetime >= ^now) and
(is_nil(m.paused) or not m.paused)
current(q, alert_ids, now) |> where([m], is_nil(m.paused) or not m.paused)
end

@doc """
Expand Down

0 comments on commit 6c50e93

Please sign in to comment.