Skip to content

Commit

Permalink
WCM-575: remove feature flag contentquery_custom_as_sql
Browse files Browse the repository at this point in the history
  • Loading branch information
Sinnaj94 committed Jan 9, 2025
1 parent dcef151 commit 9cd7062
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
10 changes: 7 additions & 3 deletions core/src/zeit/content/cp/tests/test_automatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import transaction
import zope.component

from zeit.cms.content.sources import FEATURE_TOGGLES
from zeit.cms.testcontenttype.testcontenttype import ExampleContentType
from zeit.content.cp.interfaces import IRenderedArea
import zeit.cms.content.interfaces
Expand Down Expand Up @@ -150,6 +149,7 @@ def test_builds_query_from_conditions(self):
source = zeit.cms.content.interfaces.ICommonMetadata['serie'].source(None)
autotest = source.find('Autotest')
lead.query = (('serie', 'eq', autotest),)
lead.xml.find('query').set('type', 'elastic')
lead.automatic = True
lead.automatic_type = 'custom'
IRenderedArea(lead).values()
Expand Down Expand Up @@ -184,6 +184,7 @@ def test_builds_query_with_elasticsearch_fieldname_exceptions(self):
('channels', 'eq', 'International', 'Nahost'),
('channels', 'eq', 'Wissen', None),
)
lead.xml.find('query').set('type', 'elastic')
lead.automatic = True
lead.automatic_type = 'custom'
IRenderedArea(lead).values()
Expand Down Expand Up @@ -233,6 +234,7 @@ def test_builds_query_with_condition_exception(self):
('ressort', 'eq', 'International', 'Nahost'),
('ressort', 'eq', 'Wissen', None),
)
lead.xml.find('query').set('type', 'elastic')
lead.automatic = True
lead.automatic_type = 'custom'
IRenderedArea(lead).values()
Expand Down Expand Up @@ -297,6 +299,7 @@ def test_joins_different_fields_with_AND_but_same_fields_with_OR(self):
('serie', 'eq', autotest),
('ressort', 'eq', 'Wissen', None),
)
lead.xml.find('query').set('type', 'elastic')
lead.automatic = True
lead.automatic_type = 'custom'
IRenderedArea(lead).values()
Expand Down Expand Up @@ -352,6 +355,7 @@ def test_puts_fields_into_bool_according_to_operator(self):
('serie', 'eq', autotest),
('ressort', 'neq', 'Wissen', None),
)
lead.xml.find('query').set('type', 'elastic')
lead.automatic = True
lead.automatic_type = 'custom'
IRenderedArea(lead).values()
Expand Down Expand Up @@ -442,7 +446,6 @@ def test_custom_query_order_defaults_to_semantic_publish(self):
)

def test_custom_query_can_be_forced_to_elastic(self):
FEATURE_TOGGLES.set('contentquery_custom_as_sql')
self.area.automatic_type = 'custom'
self.area.query = (('ressort', 'eq', 'International', 'Nahost'),)
self.area.xml.find('query').set('type', 'elastic')
Expand All @@ -461,6 +464,7 @@ def test_bbb_converts_automatic_type_channel_to_custom(self):
source = zeit.cms.content.interfaces.ICommonMetadata['serie'].source(None)
autotest = source.find('Autotest')
lead.query = (('serie', 'eq', autotest),)
lead.xml.find('query').set('type', 'elastic')
lead.automatic = True
lead.xml.set('automatic_type', 'channel')
IRenderedArea(lead).values()
Expand Down Expand Up @@ -1205,7 +1209,6 @@ def setUp(self):
self.area.automatic_type = 'custom'
self.repository['cp'] = self.cp
self.connector = zope.component.getUtility(zeit.connector.interfaces.IConnector)
FEATURE_TOGGLES.set('contentquery_custom_as_sql')

def test_builds_query_from_conditions(self):
source = zeit.cms.content.interfaces.ICommonMetadata['serie'].source(None)
Expand Down Expand Up @@ -1260,6 +1263,7 @@ def test_joins_different_fields_with_AND_but_same_fields_with_OR(self):
('ressort', 'eq', 'International', None),
('ressort', 'eq', 'Wissen', None),
)
self.area.xml.find('query').set('type', 'elastic')
IRenderedArea(self.area).values()
query = """
... properties.type = 'article'
Expand Down
7 changes: 1 addition & 6 deletions core/src/zeit/contentquery/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

from zeit.cms.content.cache import content_cache
from zeit.cms.content.interfaces import IUUID
from zeit.cms.content.sources import FEATURE_TOGGLES
from zeit.cms.interfaces import ICMSContent
from zeit.connector.models import TIMESTAMP
from zeit.connector.models import Content as ConnectorModel
Expand Down Expand Up @@ -292,11 +291,7 @@ def dispatch_custom_query(context):
query = context.xml.find('query')
if query is not None and query.get('type') == 'elastic':
return CustomContentQuery(context)
if FEATURE_TOGGLES.find('contentquery_custom_as_sql'):
return SQLCustomContentQuery(context)
if query is not None and query.get('type') == 'sql':
return SQLCustomContentQuery(context)
return CustomContentQuery(context)
return SQLCustomContentQuery(context)


@grok.adapter(zeit.contentquery.interfaces.IContentQuery)
Expand Down

0 comments on commit 9cd7062

Please sign in to comment.