Commit acd76c89 by Matthew Piatetsky

Remove ElasticsearchBoostConfig migrations and config

ECOM-7077
parent de83e87f
from django.contrib import admin
from solo.admin import SingletonModelAdmin
from course_discovery.apps.edx_haystack_extensions.models import ElasticsearchBoostConfig
admin.site.register(ElasticsearchBoostConfig, SingletonModelAdmin)
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import jsonfield.fields
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='ElasticsearchBoostConfig',
fields=[
('id', models.AutoField(serialize=False, auto_created=True, verbose_name='ID', primary_key=True)),
('function_score', jsonfield.fields.JSONField(help_text='JSON string containing an elasticsearch function score config.', verbose_name='Function Score', default={'boost': 5.0, 'boost_mode': 'multiply', 'functions': [], 'score_mode': 'multiply'})),
],
options={
'abstract': False,
},
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.9.10 on 2016-11-03 22:19
from __future__ import unicode_literals
import jsonfield.fields
from django.db import migrations, models
class Migration(migrations.Migration):
replaces = [('edx_haystack_extensions', '0001_initial'), ('edx_haystack_extensions', '0002_auto_20160826_1750')]
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='ElasticsearchBoostConfig',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('function_score', jsonfield.fields.JSONField(default={'boost': 1.0, 'boost_mode': 'multiply', 'functions': [], 'score_mode': 'multiply'}, help_text='JSON string containing an elasticsearch function score config.', verbose_name='Function Score')),
],
options={
'abstract': False,
},
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import jsonfield.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('edx_haystack_extensions', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='elasticsearchboostconfig',
name='function_score',
field=jsonfield.fields.JSONField(verbose_name='Function Score', help_text='JSON string containing an elasticsearch function score config.', default={'boost_mode': 'multiply', 'boost': 1.0, 'functions': [], 'score_mode': 'multiply'}),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.9.11 on 2017-01-18 18:26
from django.db import migrations
def create_or_update_config_record(apps, schema_editor):
"""Create or update the ElasticsearchBoostConfig record."""
# 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,
# These values were taken from production on January 20, 2017.
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': 'MicroMasters'}}, 'weight': 1.0},
{'linear': {'start': {'origin': 'now', 'decay': 0.95, 'scale': '1d'}}, 'weight': 5.0}
]
}
}
)
class Migration(migrations.Migration):
dependencies = [
('edx_haystack_extensions', '0001_squashed_0002_auto_20160826_1750'),
]
operations = [
migrations.RunPython(create_or_update_config_record, reverse_code=migrations.RunPython.noop)
]
# -*- 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)
]
# -*- coding: utf-8 -*-
# Generated by Django 1.9.11 on 2017-01-26 15:10
from __future__ import unicode_literals
from django.db import migrations
def add_enrollable_paid_seat_boosting(apps, schema_editor):
"""Add enrollable paid Seat boosting function to ElasticsearchBoostConfig instance."""
# 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},
# Boost function for CourseRuns with enrollable paid Seats.
# We want to boost if:
# - The course run has at least one enrollable paid Seat (has_enrollable_paid_seats is True)
# AND one of the following two conditions are true
# - The paid_seat_enrollment_end is unspecified.
# - The paid_seat_enrollment_end is in the future.
# We apply a weight of 1.0 to match the boost given for self paced courses.
{
'filter': {
'bool': {
'must': [
{'exists': {'field': 'has_enrollable_paid_seats'}},
{'term': {'has_enrollable_paid_seats': True}}
],
'should': [
{'bool': {'must_not': { 'exists': {'field': 'paid_seat_enrollment_end'}}}},
{'range': {'paid_seat_enrollment_end': {'gte': 'now'}}}
]
}
},
'weight': 1.0
}
]
}
}
)
class Migration(migrations.Migration):
dependencies = [
('edx_haystack_extensions', '0003_auto_20170124_1834'),
]
operations = [
migrations.RunPython(add_enrollable_paid_seat_boosting, migrations.RunPython.noop)
]
# -*- coding: utf-8 -*-
# Generated by Django 1.9.11 on 2017-02-01 20:43
from __future__ import unicode_literals
from django.db import migrations
def add_enrollable_course_run_boosting(apps, schema_editor):
"""Add enrollable CourseRun boosting function to ElasticsearchBoostConfig instance."""
# 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},
# Boost function for CourseRuns with enrollable paid Seats.
# We want to boost if:
# - The course run has at least one enrollable paid Seat (has_enrollable_paid_seats is True)
# AND one of the following two conditions are true
# - The paid_seat_enrollment_end is unspecified.
# - The paid_seat_enrollment_end is in the future.
# We apply a weight of 1.0 to match the boost given for self paced courses.
{
'filter': {
'bool': {
'must': [
{'exists': {'field': 'has_enrollable_paid_seats'}},
{'term': {'has_enrollable_paid_seats': True}}
],
'should': [
{'bool': {'must_not': { 'exists': {'field': 'paid_seat_enrollment_end'}}}},
{'range': {'paid_seat_enrollment_end': {'gte': 'now'}}}
]
}
},
'weight': 1.0
},
# Boost function for enrollable CourseRuns.
# We want to boost if:
# - enrollment_start and enrollment_end are unspecified
# - enrollment_start is unspecified and enrollment_end is in the future
# - enrollment_end is unspecified and enrollment_start is in the past
# - enrollment_start is in the past and enrollment_end is in the future
# We apply a weight of 1.0 to match the boost given for self paced and enrollable paid courses.
{
'filter': {
'bool': {
'should': [
{'bool': {
'must_not': [
{'exists': {'field': 'enrollment_start'}},
{'exists': {'field': 'enrollment_end'}}
]
}},
{'bool': {
'must_not': {'exists': {'field': 'enrollment_start'}},
'must': [
{'exists': {'field': 'enrollment_end'}},
{'range': {'enrollment_end': {'gt': 'now'}}}
]
}},
{'bool': {
'must_not': {'exists': {'field': 'enrollment_end'}},
'must': [
{'exists': {'field': 'enrollment_start'}},
{'range': {'enrollment_start': {'lte': 'now'}}}
]
}},
{'bool': {
'must': [
{'exists': {'field': 'enrollment_start'}},
{'exists': {'field': 'enrollment_end'}},
{'range': {'enrollment_start': {'lte': 'now'}}},
{'range': {'enrollment_end': {'gt': 'now'}}}
]
}}
]
}
},
'weight': 1.0
}
]
}
}
)
class Migration(migrations.Migration):
dependencies = [
('edx_haystack_extensions', '0004_auto_20170126_1510'),
]
operations = [
migrations.RunPython(add_enrollable_course_run_boosting, migrations.RunPython.noop)
]
from django.utils.translation import ugettext_lazy as _
from jsonfield.fields import JSONField
from solo.models import SingletonModel
class ElasticsearchBoostConfig(SingletonModel):
"""
Model used to store the elasticsearch boost configuration.
This includes a default JSON config for the function_score.
"""
function_score = JSONField(
verbose_name=_('Function Score'),
help_text=_('JSON string containing an elasticsearch function score config.'),
null=False,
blank=False,
default={
'functions': [],
'boost': 1.0,
'score_mode': 'multiply',
'boost_mode': 'multiply'
}
)
...@@ -7,14 +7,14 @@ msgid "" ...@@ -7,14 +7,14 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-02-16 14:33+0500\n" "POT-Creation-Date: 2017-02-16 10:21-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Language: \n"
#: apps/api/filters.py #: apps/api/filters.py
#, python-brace-format #, python-brace-format
...@@ -424,14 +424,6 @@ msgstr "" ...@@ -424,14 +424,6 @@ msgstr ""
msgid "Change program excluded course runs" msgid "Change program excluded course runs"
msgstr "" msgstr ""
#: apps/edx_haystack_extensions/models.py
msgid "Function Score"
msgstr ""
#: apps/edx_haystack_extensions/models.py
msgid "JSON string containing an elasticsearch function score config."
msgstr ""
#: apps/publisher/api/serializers.py #: apps/publisher/api/serializers.py
#, python-brace-format #, python-brace-format
msgid "Invalid course key \"{lms_course_id}\"" msgid "Invalid course key \"{lms_course_id}\""
......
...@@ -7,14 +7,14 @@ msgid "" ...@@ -7,14 +7,14 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-02-16 14:33+0500\n" "POT-Creation-Date: 2017-02-16 10:21-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Language: \n"
#: static/js/catalogs-change-form.js #: static/js/catalogs-change-form.js
msgid "Preview" msgid "Preview"
......
...@@ -7,14 +7,14 @@ msgid "" ...@@ -7,14 +7,14 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-02-16 14:33+0500\n" "POT-Creation-Date: 2017-02-16 10:21-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Language: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: apps/api/filters.py #: apps/api/filters.py
...@@ -534,16 +534,6 @@ msgid "Change program excluded course runs" ...@@ -534,16 +534,6 @@ msgid "Change program excluded course runs"
msgstr "" msgstr ""
"Çhängé prögräm éxçlüdéd çöürsé rüns Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢σηѕє¢тєт#" "Çhängé prögräm éxçlüdéd çöürsé rüns Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢σηѕє¢тєт#"
#: apps/edx_haystack_extensions/models.py
msgid "Function Score"
msgstr "Fünçtïön Sçöré Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт#"
#: apps/edx_haystack_extensions/models.py
msgid "JSON string containing an elasticsearch function score config."
msgstr ""
"JSÖN strïng çöntäïnïng än élästïçséärçh fünçtïön sçöré çönfïg. Ⱡ'σяєм ιρѕυм "
"∂σłσя ѕιт αмєт, ¢σηѕє¢тєтυя α#"
#: apps/publisher/api/serializers.py #: apps/publisher/api/serializers.py
#, python-brace-format #, python-brace-format
msgid "Invalid course key \"{lms_course_id}\"" msgid "Invalid course key \"{lms_course_id}\""
......
...@@ -7,14 +7,14 @@ msgid "" ...@@ -7,14 +7,14 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-02-16 14:33+0500\n" "POT-Creation-Date: 2017-02-16 10:21-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Language: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: static/js/catalogs-change-form.js #: static/js/catalogs-change-form.js
......
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