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
2ee54bbb
Commit
2ee54bbb
authored
Apr 14, 2017
by
Matthew Piatetsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more data to search results
LEARNER-799
parent
f2ad580e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
5 deletions
+26
-5
course_discovery/apps/api/serializers.py
+6
-3
course_discovery/apps/api/tests/test_serializers.py
+7
-0
course_discovery/apps/api/v1/tests/test_views/test_programs.py
+4
-1
course_discovery/apps/course_metadata/search_indexes.py
+5
-0
course_discovery/apps/course_metadata/tests/test_models.py
+4
-1
No files found.
course_discovery/apps/api/serializers.py
View file @
2ee54bbb
...
...
@@ -53,7 +53,7 @@ COURSE_RUN_SEARCH_FIELDS = (
'enrollment_end'
,
'pacing_type'
,
'language'
,
'transcript_languages'
,
'marketing_url'
,
'content_type'
,
'org'
,
'number'
,
'seat_types'
,
'image_url'
,
'type'
,
'level_type'
,
'availability'
,
'published'
,
'partner'
,
'program_types'
,
'authoring_organization_uuids'
,
'subject_uuids'
,
'staff_uuids'
,
'mobile_available'
,
'logo_image_urls'
,
'aggregation_key'
,
'aggregation_key'
,
'min_effort'
,
'max_effort'
,
'weeks_to_complete'
,
)
PROGRAM_FACET_FIELD_OPTIONS
=
{
...
...
@@ -67,8 +67,11 @@ BASE_PROGRAM_FIELDS = (
'published'
,
'partner'
,
)
PROGRAM_SEARCH_FIELDS
=
BASE_PROGRAM_FIELDS
+
(
'aggregation_key'
,
'authoring_organizations'
,
'authoring_organization_uuids'
,
'subject_uuids'
,
'staff_uuids'
,)
PROGRAM_SEARCH_FIELDS
=
BASE_PROGRAM_FIELDS
+
(
'aggregation_key'
,
'authoring_organizations'
,
'authoring_organization_uuids'
,
'subject_uuids'
,
'staff_uuids'
,
'weeks_to_complete_min'
,
'weeks_to_complete_max'
,
'min_hours_effort_per_week'
,
'max_hours_effort_per_week'
,
)
PROGRAM_FACET_FIELDS
=
BASE_PROGRAM_FIELDS
+
(
'organizations'
,)
PREFETCH_FIELDS
=
{
...
...
course_discovery/apps/api/tests/test_serializers.py
View file @
2ee54bbb
...
...
@@ -1154,6 +1154,9 @@ class CourseRunSearchSerializerTests(ElasticsearchTestMixin, TestCase):
orgs
=
course_run
.
authoring_organizations
.
all
()
expected
=
{
'transcript_languages'
:
[
serialize_language
(
l
)
for
l
in
course_run
.
transcript_languages
.
all
()],
'min_effort'
:
course_run
.
min_effort
,
'max_effort'
:
course_run
.
max_effort
,
'weeks_to_complete'
:
course_run
.
weeks_to_complete
,
'short_description'
:
course_run
.
short_description
,
'start'
:
serialize_datetime
(
course_run
.
start
),
'end'
:
serialize_datetime
(
course_run
.
end
),
...
...
@@ -1216,6 +1219,10 @@ class ProgramSearchSerializerTests(TestCase):
'subject_uuids'
:
get_uuids
([
course
.
subjects
for
course
in
program
.
courses
.
all
()]),
'staff_uuids'
:
get_uuids
([
course
.
staff
for
course
in
list
(
program
.
course_runs
)]),
'aggregation_key'
:
'program:{}'
.
format
(
program
.
uuid
),
'weeks_to_complete_min'
:
program
.
weeks_to_complete_min
,
'weeks_to_complete_max'
:
program
.
weeks_to_complete_max
,
'min_hours_effort_per_week'
:
program
.
min_hours_effort_per_week
,
'max_hours_effort_per_week'
:
program
.
max_hours_effort_per_week
,
}
def
test_data
(
self
):
...
...
course_discovery/apps/api/v1/tests/test_views/test_programs.py
View file @
2ee54bbb
...
...
@@ -75,7 +75,8 @@ class ProgramViewSetTests(SerializationMixin, APITestCase):
program
=
self
.
create_program
()
with
self
.
assertNumQueries
(
42
):
response
=
self
.
assert_retrieve_success
(
program
)
# property does not have the right values while being indexed
del
program
.
_course_run_weeks_to_complete
assert
response
.
data
==
self
.
serialize_program
(
program
)
# Verify that repeated retrieve requests use the cache.
...
...
@@ -93,6 +94,8 @@ class ProgramViewSetTests(SerializationMixin, APITestCase):
for
course
in
course_list
:
CourseRunFactory
(
course
=
course
)
program
=
ProgramFactory
(
courses
=
course_list
,
order_courses_by_start_date
=
order_courses_by_start_date
)
# property does not have the right values while being indexed
del
program
.
_course_run_weeks_to_complete
with
self
.
assertNumQueries
(
29
):
response
=
self
.
assert_retrieve_success
(
program
)
assert
response
.
data
==
self
.
serialize_program
(
program
)
...
...
course_discovery/apps/course_metadata/search_indexes.py
View file @
2ee54bbb
...
...
@@ -140,6 +140,7 @@ class CourseRunIndex(BaseCourseIndex, indexes.Indexable):
announcement
=
indexes
.
DateTimeField
(
model_attr
=
'announcement'
,
null
=
True
)
min_effort
=
indexes
.
IntegerField
(
model_attr
=
'min_effort'
,
null
=
True
)
max_effort
=
indexes
.
IntegerField
(
model_attr
=
'max_effort'
,
null
=
True
)
weeks_to_complete
=
indexes
.
IntegerField
(
model_attr
=
'weeks_to_complete'
,
null
=
True
)
language
=
indexes
.
CharField
(
null
=
True
,
faceted
=
True
)
transcript_languages
=
indexes
.
MultiValueField
(
faceted
=
True
)
pacing_type
=
indexes
.
CharField
(
model_attr
=
'pacing_type'
,
null
=
True
,
faceted
=
True
)
...
...
@@ -235,6 +236,10 @@ class ProgramIndex(BaseIndex, indexes.Indexable, OrganizationsMixin):
start
=
indexes
.
DateTimeField
(
model_attr
=
'start'
,
null
=
True
,
faceted
=
True
)
seat_types
=
indexes
.
MultiValueField
(
model_attr
=
'seat_types'
,
null
=
True
,
faceted
=
True
)
published
=
indexes
.
BooleanField
(
null
=
False
,
faceted
=
True
)
min_hours_effort_per_week
=
indexes
.
IntegerField
(
model_attr
=
'min_hours_effort_per_week'
,
null
=
True
)
max_hours_effort_per_week
=
indexes
.
IntegerField
(
model_attr
=
'max_hours_effort_per_week'
,
null
=
True
)
weeks_to_complete_min
=
indexes
.
IntegerField
(
model_attr
=
'weeks_to_complete_min'
,
null
=
True
)
weeks_to_complete_max
=
indexes
.
IntegerField
(
model_attr
=
'weeks_to_complete_max'
,
null
=
True
)
def
prepare_aggregation_key
(
self
,
obj
):
return
'program:{}'
.
format
(
obj
.
uuid
)
...
...
course_discovery/apps/course_metadata/tests/test_models.py
View file @
2ee54bbb
...
...
@@ -434,7 +434,8 @@ class ProgramTests(TestCase):
transcript_languages
=
LanguageTag
.
objects
.
all
()[:
2
]
subjects
=
factories
.
SubjectFactory
.
create_batch
(
2
)
self
.
course_runs
=
factories
.
CourseRunFactory
.
create_batch
(
3
,
transcript_languages
=
transcript_languages
,
course__subjects
=
subjects
)
3
,
transcript_languages
=
transcript_languages
,
course__subjects
=
subjects
,
weeks_to_complete
=
2
)
self
.
courses
=
[
course_run
.
course
for
course_run
in
self
.
course_runs
]
self
.
excluded_course_run
=
factories
.
CourseRunFactory
(
course
=
self
.
courses
[
0
])
self
.
program
=
factories
.
ProgramFactory
(
courses
=
self
.
courses
,
excluded_course_runs
=
[
self
.
excluded_course_run
])
...
...
@@ -601,6 +602,8 @@ class ProgramTests(TestCase):
weeks_to_complete_values
=
[
course_run
.
weeks_to_complete
for
course_run
in
self
.
course_runs
]
expected_min
=
min
(
weeks_to_complete_values
)
if
weeks_to_complete_values
else
None
expected_max
=
max
(
weeks_to_complete_values
)
if
weeks_to_complete_values
else
None
# property does not have the right values while being indexed
del
self
.
program
.
_course_run_weeks_to_complete
self
.
assertEqual
(
self
.
program
.
weeks_to_complete_min
,
expected_min
)
self
.
assertEqual
(
self
.
program
.
weeks_to_complete_max
,
expected_max
)
...
...
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