Skip to content

Commit

Permalink
mod_mailinglist: more efficient query for polling scheduled mailings.
Browse files Browse the repository at this point in the history
  • Loading branch information
mworrell committed Mar 27, 2015
1 parent be31419 commit 18bb8f1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions modules/mod_mailinglist/models/m_mailinglist.erl
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,16 @@ get_scheduled(Id, Context) ->
%% @doc Fetch the next scheduled mailing that is publicly visible, published and in the publication date range.
check_scheduled(Context) ->
z_db:q_row("
select m.mailinglist_id, m.page_id
select m.mailinglist_id, m.page_id
from mailinglist_scheduled m
join rsc r on m.page_id = r.id
where r.is_published
and r.visible_for = 0
and r.publication_start <= now()
and r.publication_end >= now()
where (
select r.is_published
and r.visible_for = 0
and r.publication_start <= now()
and r.publication_end >= now()
from rsc r
where r.id = m.mailinglist_id
)
limit 1", Context).


Expand Down

0 comments on commit 18bb8f1

Please sign in to comment.