Skip to content

Commit

Permalink
Change Default sort to featured (#1377)
Browse files Browse the repository at this point in the history
  • Loading branch information
abeglova authored Aug 13, 2024
1 parent 479f652 commit 5e2aa50
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions learning_resources_search/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from opensearch_dsl.query import MoreLikeThis, Percolate
from opensearchpy.exceptions import NotFoundError

from learning_resources.constants import LEARNING_RESOURCE_SORTBY_OPTIONS
from learning_resources.models import LearningResource
from learning_resources_search.connection import (
get_default_alias_name,
Expand All @@ -21,6 +20,7 @@
DEPARTMENT_QUERY_FIELDS,
LEARNING_RESOURCE,
LEARNING_RESOURCE_QUERY_FIELDS,
LEARNING_RESOURCE_SEARCH_SORTBY_OPTIONS,
LEARNING_RESOURCE_TYPES,
RESOURCEFILE_QUERY_FIELDS,
RUN_INSTRUCTORS_QUERY_FIELDS,
Expand All @@ -39,7 +39,7 @@

LEARN_SUGGEST_FIELDS = ["title.trigram", "description.trigram"]
COURSENUM_SORT_FIELD = "course.course_numbers.sort_coursenum"
DEFAULT_SORT = ["is_learning_material", "-views"]
DEFAULT_SORT = ["featured_rank", "is_learning_material"]


def gen_content_file_id(content_file_id):
Expand Down Expand Up @@ -89,7 +89,7 @@ def generate_sort_clause(search_params):
"""

sort = (
LEARNING_RESOURCE_SORTBY_OPTIONS.get(search_params.get("sortby"), {})
LEARNING_RESOURCE_SEARCH_SORTBY_OPTIONS.get(search_params.get("sortby"), {})
.get("sort")
.replace("0__", "")
.replace("__", ".")
Expand Down
2 changes: 1 addition & 1 deletion learning_resources_search/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2202,7 +2202,7 @@ def test_document_percolation(opensearch, mocker):
[
("-views", None, [{"views": {"order": "desc"}}]),
("-views", "text", [{"views": {"order": "desc"}}]),
(None, None, ["is_learning_material", {"views": {"order": "desc"}}]),
(None, None, ["featured_rank", "is_learning_material"]),
(None, "text", None),
],
)
Expand Down

0 comments on commit 5e2aa50

Please sign in to comment.