Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
course-discovery
Commits
54214329
Commit
54214329
authored
Mar 08, 2017
by
Matthew Piatetsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turn off index updates on model save
ECOM-7346
parent
3fa7c15f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
8 deletions
+16
-8
course_discovery/apps/api/tests/test_serializers.py
+2
-0
course_discovery/apps/api/v1/tests/test_views/test_search.py
+4
-0
course_discovery/apps/course_metadata/models.py
+10
-8
No files found.
course_discovery/apps/api/tests/test_serializers.py
View file @
54214329
...
@@ -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
()])
...
...
course_discovery/apps/api/v1/tests/test_views/test_search.py
View file @
54214329
...
@@ -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
}],
...
...
course_discovery/apps/course_metadata/models.py
View file @
54214329
...
@@ -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
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment