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
cba37b58
Commit
cba37b58
authored
Jan 24, 2017
by
Matthew Piatetsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Boost Professional Certificates above XSeries
ECOM-6780
parent
4e0569de
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
5 deletions
+47
-5
course_discovery/apps/api/v1/tests/test_views/test_search.py
+7
-5
course_discovery/apps/edx_haystack_extensions/migrations/0003_auto_20170124_1834.py
+40
-0
No files found.
course_discovery/apps/api/v1/tests/test_views/test_search.py
View file @
cba37b58
...
@@ -324,6 +324,7 @@ class AggregateSearchViewSet(DefaultPartnerMixin, SerializationMixin, LoginMixin
...
@@ -324,6 +324,7 @@ class AggregateSearchViewSet(DefaultPartnerMixin, SerializationMixin, LoginMixin
self
.
assertEqual
(
response
.
data
[
'objects'
][
'results'
],
expected
)
self
.
assertEqual
(
response
.
data
[
'objects'
][
'results'
],
expected
)
@ddt.ddt
class
TypeaheadSearchViewTests
(
DefaultPartnerMixin
,
TypeaheadSerializationMixin
,
LoginMixin
,
ElasticsearchTestMixin
,
class
TypeaheadSearchViewTests
(
DefaultPartnerMixin
,
TypeaheadSerializationMixin
,
LoginMixin
,
ElasticsearchTestMixin
,
APITestCase
):
APITestCase
):
path
=
reverse
(
'api:v1:search-typeahead'
)
path
=
reverse
(
'api:v1:search-typeahead'
)
...
@@ -418,9 +419,10 @@ class TypeaheadSearchViewTests(DefaultPartnerMixin, TypeaheadSerializationMixin,
...
@@ -418,9 +419,10 @@ class TypeaheadSearchViewTests(DefaultPartnerMixin, TypeaheadSerializationMixin,
self
.
assertEqual
(
response
.
status_code
,
400
)
self
.
assertEqual
(
response
.
status_code
,
400
)
self
.
assertEqual
(
response
.
data
,
[
"The 'q' querystring parameter is required for searching."
])
self
.
assertEqual
(
response
.
data
,
[
"The 'q' querystring parameter is required for searching."
])
def
test_micromasters_boosting
(
self
):
@ddt.data
(
'MicroMasters'
,
'Professional Certificate'
)
""" Verify micromasters are boosted over xseries."""
def
test_program_type_boosting
(
self
,
program_type
):
title
=
"micromasters"
""" Verify MicroMasters and Professional Certificate are boosted over XSeries."""
title
=
program_type
ProgramFactory
(
ProgramFactory
(
title
=
title
+
"1"
,
status
=
ProgramStatus
.
Active
,
title
=
title
+
"1"
,
status
=
ProgramStatus
.
Active
,
type
=
ProgramType
.
objects
.
get
(
name
=
'XSeries'
),
partner
=
self
.
partner
type
=
ProgramType
.
objects
.
get
(
name
=
'XSeries'
),
partner
=
self
.
partner
...
@@ -428,13 +430,13 @@ class TypeaheadSearchViewTests(DefaultPartnerMixin, TypeaheadSerializationMixin,
...
@@ -428,13 +430,13 @@ class TypeaheadSearchViewTests(DefaultPartnerMixin, TypeaheadSerializationMixin,
ProgramFactory
(
ProgramFactory
(
title
=
title
+
"2"
,
title
=
title
+
"2"
,
status
=
ProgramStatus
.
Active
,
status
=
ProgramStatus
.
Active
,
type
=
ProgramType
.
objects
.
get
(
name
=
'MicroMasters'
),
type
=
ProgramType
.
objects
.
get
(
name
=
program_type
),
partner
=
self
.
partner
partner
=
self
.
partner
)
)
response
=
self
.
get_typeahead_response
(
title
)
response
=
self
.
get_typeahead_response
(
title
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
response_data
=
response
.
json
()
response_data
=
response
.
json
()
self
.
assertEqual
(
response_data
[
'programs'
][
0
][
'type'
],
'MicroMasters'
)
self
.
assertEqual
(
response_data
[
'programs'
][
0
][
'type'
],
program_type
)
self
.
assertEqual
(
response_data
[
'programs'
][
0
][
'title'
],
title
+
"2"
)
self
.
assertEqual
(
response_data
[
'programs'
][
0
][
'title'
],
title
+
"2"
)
def
test_start_date_boosting
(
self
):
def
test_start_date_boosting
(
self
):
...
...
course_discovery/apps/edx_haystack_extensions/migrations/0003_auto_20170124_1834.py
0 → 100644
View file @
cba37b58
# -*- coding: utf-8 -*-
# Generated by Django 1.9.11 on 2017-01-24 18:34
from
__future__
import
unicode_literals
from
django.db
import
migrations
def
add_professional_certificate_boosting
(
apps
,
schema_editor
):
""" Update ElasticsearchBoostConfig to include professional certificate boosting."""
# Get the model from the versioned app registry to ensure the correct version is used, as described in
# https://docs.djangoproject.com/en/1.8/ref/migration-operations/#runpython
ElasticsearchBoostConfig
=
apps
.
get_model
(
'edx_haystack_extensions'
,
'ElasticsearchBoostConfig'
)
ElasticsearchBoostConfig
.
objects
.
update_or_create
(
# The `solo` library uses 1 for the PrimaryKey to create/lookup the singleton record
# See https://github.com/lazybird/django-solo/blob/1.1.2/solo/models.py
pk
=
1
,
defaults
=
{
'function_score'
:
{
'boost_mode'
:
'sum'
,
'boost'
:
1.0
,
'score_mode'
:
'sum'
,
'functions'
:
[
{
'filter'
:
{
'term'
:
{
'pacing_type_exact'
:
'self_paced'
}},
'weight'
:
1.0
},
{
'filter'
:
{
'term'
:
{
'type_exact'
:
'Professional Certificate'
}},
'weight'
:
1.0
},
{
'filter'
:
{
'term'
:
{
'type_exact'
:
'MicroMasters'
}},
'weight'
:
1.0
},
{
'linear'
:
{
'start'
:
{
'origin'
:
'now'
,
'decay'
:
0.95
,
'scale'
:
'1d'
}},
'weight'
:
5.0
}
]
}
}
)
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'edx_haystack_extensions'
,
'0002_auto_20170118_1826'
),
]
operations
=
[
migrations
.
RunPython
(
add_professional_certificate_boosting
,
migrations
.
RunPython
.
noop
)
]
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