Commit cba37b58 by Matthew Piatetsky

Boost Professional Certificates above XSeries

ECOM-6780
parent 4e0569de
...@@ -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):
......
# -*- 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)
]
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