Commit 54214329 by Matthew Piatetsky

Turn off index updates on model save

ECOM-7346
parent 3fa7c15f
...@@ -3,6 +3,7 @@ import datetime ...@@ -3,6 +3,7 @@ import datetime
from urllib.parse import urlencode from urllib.parse import urlencode
import ddt import ddt
import pytest
import pytz import pytz
from django.test import TestCase from django.test import TestCase
from haystack.query import SearchQuerySet from haystack.query import SearchQuerySet
...@@ -1191,6 +1192,7 @@ class CourseSearchSerializerTests(TestCase): ...@@ -1191,6 +1192,7 @@ class CourseSearchSerializerTests(TestCase):
class CourseRunSearchSerializerTests(TestCase): class CourseRunSearchSerializerTests(TestCase):
@pytest.mark.skip(reason="turning off temporarily for experiment - ECOM-7346")
def test_data(self): def test_data(self):
course_run = CourseRunFactory(transcript_languages=LanguageTag.objects.filter(code__in=['en-us', 'zh-cn']), course_run = CourseRunFactory(transcript_languages=LanguageTag.objects.filter(code__in=['en-us', 'zh-cn']),
authoring_organizations=[OrganizationFactory()]) authoring_organizations=[OrganizationFactory()])
......
...@@ -3,6 +3,7 @@ import json ...@@ -3,6 +3,7 @@ import json
import urllib.parse import urllib.parse
import ddt import ddt
import pytest
from django.conf import settings from django.conf import settings
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from haystack.query import SearchQuerySet from haystack.query import SearchQuerySet
...@@ -234,14 +235,17 @@ class CourseRunSearchViewSetTests(DefaultPartnerMixin, SerializationMixin, Login ...@@ -234,14 +235,17 @@ class CourseRunSearchViewSetTests(DefaultPartnerMixin, SerializationMixin, Login
} }
self.assertDictContainsSubset(expected, response_data['queries']) self.assertDictContainsSubset(expected, response_data['queries'])
@pytest.mark.skip(reason="turning off temporarily for experiment - ECOM-7346")
def test_exclude_deleted_program_types(self): def test_exclude_deleted_program_types(self):
""" Verify the deleted programs do not show in the program_types representation. """ """ Verify the deleted programs do not show in the program_types representation. """
self._test_exclude_program_types(ProgramStatus.Deleted) self._test_exclude_program_types(ProgramStatus.Deleted)
@pytest.mark.skip(reason="turning off temporarily for experiment - ECOM-7346")
def test_exclude_unpublished_program_types(self): def test_exclude_unpublished_program_types(self):
""" Verify the unpublished programs do not show in the program_types representation. """ """ Verify the unpublished programs do not show in the program_types representation. """
self._test_exclude_program_types(ProgramStatus.Unpublished) self._test_exclude_program_types(ProgramStatus.Unpublished)
@pytest.mark.skip(reason="turning off temporarily for experiment - ECOM-7346")
@ddt.data( @ddt.data(
[{'title': 'Software Testing', 'excluded': True}], [{'title': 'Software Testing', 'excluded': True}],
[{'title': 'Software Testing', 'excluded': True}, {'title': 'Software Testing 2', 'excluded': True}], [{'title': 'Software Testing', 'excluded': True}, {'title': 'Software Testing 2', 'excluded': True}],
......
...@@ -333,13 +333,14 @@ class Course(TimeStampedModel): ...@@ -333,13 +333,14 @@ class Course(TimeStampedModel):
ids = [result.pk for result in results] ids = [result.pk for result in results]
return cls.objects.filter(pk__in=ids) return cls.objects.filter(pk__in=ids)
def save(self, *args, **kwargs): # This is commented out for a temporary experiment for ECOM-7346
super(Course, self).save(*args, **kwargs) # def save(self, *args, **kwargs):
try: # super(Course, self).save(*args, **kwargs)
self.reindex_course_runs() # try:
except Exception: # pylint: disable=broad-except # self.reindex_course_runs()
logger.exception("An error occurred while attempting to reindex the course runs" # except Exception: # pylint: disable=broad-except
"of Course with key: [{key}].".format(key=self.key)) # logger.exception("An error occurred while attempting to reindex the course runs"
# "of Course with key: [{key}].".format(key=self.key))
def reindex_course_runs(self): def reindex_course_runs(self):
index = connections['default'].get_unified_index().get_index(CourseRun) index = connections['default'].get_unified_index().get_index(CourseRun)
...@@ -938,7 +939,8 @@ class Program(TimeStampedModel): ...@@ -938,7 +939,8 @@ class Program(TimeStampedModel):
publisher.publish_program(self) publisher.publish_program(self)
else: else:
super(Program, self).save(*args, **kwargs) super(Program, self).save(*args, **kwargs)
self.reindex_courses() # This is commented out for a temporary experiment for ECOM-7346
# self.reindex_courses()
def reindex_courses(self): def reindex_courses(self):
try: try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment