Updated new-api-search to use a flag for incremental rollout.

This commit is contained in:
Rob Hudson 2012-02-09 09:36:53 -08:00
Родитель 34106c6716
Коммит cafeae8f9e
5 изменённых файлов: 7 добавлений и 4 удалений

Просмотреть файл

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
{% if using_ES %}<!-- Using elasticsearch. Hi Krupa! -->{% endif %}
<searchresults total_results="{{ total }}">
{% if addons_xml %}
{% for xml in addons_xml %}

Просмотреть файл

@ -769,7 +769,7 @@ class SearchTest(ESTestCase):
self.refresh()
# TODO(robhudson): Remove when we officially switch.
waffle.models.Switch.objects.create(name='new-api-search', active=True)
waffle.models.Flag.objects.create(name='new-api-search', everyone=True)
def test_double_escaping(self):
"""

Просмотреть файл

@ -304,7 +304,7 @@ class SearchView(APIView):
"""
Query the search backend and serve up the XML.
"""
if not waffle.switch_is_active('new-api-search'):
if not waffle.flag_is_active(self.request, 'new-api-search'):
return self._sphinx_api_search(query, addon_type, limit, platform,
version, compat_mode)
@ -342,7 +342,6 @@ class SearchView(APIView):
qs = qs.filter(**filters)
return self.render('api/search.xml', {
'using_ES': True,
'results': qs[:limit],
'total': qs.count(),
})

Просмотреть файл

@ -307,6 +307,7 @@ MIDDLEWARE_CLASSES = (
'commonware.middleware.FrameOptionsHeader',
'commonware.middleware.StrictTransportMiddleware',
'multidb.middleware.PinningRouterMiddleware',
'waffle.middleware.WaffleMiddleware',
'csp.middleware.CSPMiddleware',

Просмотреть файл

@ -0,0 +1,4 @@
INSERT INTO `waffle_flag`
(name, everyone, percent, superusers, staff, authenticated, rollout, note) VALUES
('new-api-search', 0, NULL, 0, 0, 0, 0, 'Enables the ES backed for API search (away from Sphinx).');
DELETE FROM waffle_switch WHERE name='new-api-search';