create or replace view movie_showtimes_with_current_and_sold_out as
select *
  from movie_showtimes_with_current_and_sold_out_and_dirty_and_expiry
where dirty is false
  and (expiry is null or expiry > nowe())
union all
select *,
       false, 
       movie_showtimes_refresh_row(w.id)
  from movie_showtimes_with_current_and_sold_out_unmaterialized w
where id in (select id
               from movie_showtimes_with_current_and_sold_out_and_dirty_and_expiry
               where dirty is true
                 or not(expiry is null or now() <= expiry);


