Module: Alchemy::Page::PageScopes::ClassMethods

Defined in:
app/models/alchemy/page/page_scopes.rb

Instance Method Summary collapse

Instance Method Details

#not_public(time = Time.current) ⇒ Object

All pages that do not have any public version


108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'app/models/alchemy/page/page_scopes.rb', line 108

def not_public(time = Time.current)
  where <<~SQL
    alchemy_pages.id NOT IN (
      SELECT alchemy_page_versions.page_id
      FROM alchemy_page_versions
      WHERE alchemy_page_versions.public_on <= '#{connection.quoted_date(time)}'
      AND (
        alchemy_page_versions.public_until IS NULL
        OR alchemy_page_versions.public_until >= '#{connection.quoted_date(time)}'
      )
    )
  SQL
end