From 901d9203c8a7e7b08085cff9b8cd2df7df6eda19 Mon Sep 17 00:00:00 2001 From: Anton Suharev Date: Thu, 26 Sep 2024 11:57:52 -0700 Subject: [PATCH 1/4] set initial ordering to `relevance` in the frontend component --- frontend/src/components/CodebaseListSidebar.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/CodebaseListSidebar.vue b/frontend/src/components/CodebaseListSidebar.vue index 8a0063db6..7d1a13122 100644 --- a/frontend/src/components/CodebaseListSidebar.vue +++ b/frontend/src/components/CodebaseListSidebar.vue @@ -141,7 +141,7 @@ const initializeFilterValues = () => { values.endDate = urlParams.get("publishedBefore") ? new Date(urlParams.get("publishedBefore")!) : null; - values.ordering = urlParams.get("ordering") || "-first_published_at"; + values.ordering = urlParams.get("ordering") || "relevance"; initialFilterValues.value = { ...values }; }; From 295dd6d49f606ceb485a1cf6f34da0bfeebc60f6 Mon Sep 17 00:00:00 2001 From: Anton Suharev Date: Mon, 14 Oct 2024 15:01:18 -0700 Subject: [PATCH 2/4] fix: if search query is empty, the ordering parameter should default to -first_publiched_at --- frontend/src/components/CodebaseListSidebar.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/CodebaseListSidebar.vue b/frontend/src/components/CodebaseListSidebar.vue index 7d1a13122..4e8a82e9f 100644 --- a/frontend/src/components/CodebaseListSidebar.vue +++ b/frontend/src/components/CodebaseListSidebar.vue @@ -141,7 +141,8 @@ const initializeFilterValues = () => { values.endDate = urlParams.get("publishedBefore") ? new Date(urlParams.get("publishedBefore")!) : null; - values.ordering = urlParams.get("ordering") || "relevance"; + values.ordering = + urlParams.get("ordering") || (urlParams.get("query") ? "relevance" : "-first_published_at"); initialFilterValues.value = { ...values }; }; From 4a2e962407626a785c080deed947d79801119a2e Mon Sep 17 00:00:00 2001 From: Allen Lee Date: Tue, 15 Oct 2024 14:19:09 -0700 Subject: [PATCH 3/4] deps: pin MarkupSafe for regression in 3.0.x refs https://github.com/comses/planning/issues/277 --- django/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/django/requirements.txt b/django/requirements.txt index a26f31403..3ec7ca983 100644 --- a/django/requirements.txt +++ b/django/requirements.txt @@ -30,6 +30,7 @@ html2text>=2016.9.19 jinja2==3.1.4 jsonschema==4.19.0 markdown==3.6 +MarkupSafe<3.0.0 # FIXME: remove after regression in 3.0.x is patched https://github.com/comses/planning/issues/277 nltk>=3.8.1,<4.0.0 numpy==1.26.4 pandas==2.2.2 From 971d6ab1e78d254da916b6602b3dee846b1b62f9 Mon Sep 17 00:00:00 2001 From: Allen Lee Date: Tue, 15 Oct 2024 17:10:11 -0700 Subject: [PATCH 4/4] fix: minor text refinement change to "clear search" and include for queries as well we should not list a sort by relevance when there is no search query --- django/core/jinja2/base.jinja | 2 +- django/core/jinja2/common.jinja | 67 ++++++++++++++++++--------------- django/core/pagination.py | 6 +-- 3 files changed, 40 insertions(+), 35 deletions(-) diff --git a/django/core/jinja2/base.jinja b/django/core/jinja2/base.jinja index 054aa9fa1..299f80e9d 100644 --- a/django/core/jinja2/base.jinja +++ b/django/core/jinja2/base.jinja @@ -354,7 +354,7 @@ {% if not is_production() %} -
+
You are currently accessing a test version of the comses.net website. Information that you view or store here will not be preserved and may not be consistent. diff --git a/django/core/jinja2/common.jinja b/django/core/jinja2/common.jinja index d7b2cff91..b0fc5347e 100644 --- a/django/core/jinja2/common.jinja +++ b/django/core/jinja2/common.jinja @@ -109,8 +109,9 @@
{% endmacro %} -{% macro build_paginator_url_params(page_number, query_params) %}{%- if query_params %}{{ query_params }}&{%endif --%}page={{page_number}}{% endmacro %} +{% macro build_paginator_url_params(page_number, query_params) %} +{%- if query_params %}{{ query_params }}&{%endif-%}page={{page_number}} +{% endmacro %} {% macro page_nav(url_name, list_state) %} {% endmacro %} {% macro paginator(url_name, list_state) %} -

Displaying {{ list_state.num_results }} of {{ list_state.count }} results - {% if list_state.query %} - for '{{ list_state.query }}' - {% endif %} - {% if list_state.filter_display_terms %} - {% for term in list_state.filter_display_terms %} - {{ term }} - {% endfor %} - - clear filters - +

Displaying {{ list_state.num_results }} of {{ list_state.count }} results + {% if list_state.query or list_state.filter_display_terms %} + {% if list_state.query %} + for "{{ list_state.query }}" + {% endif %} + {% if list_state.filter_display_terms %} + {% for term in list_state.filter_display_terms %} + {{ term }} + {% endfor %} + {% endif %} + + clear search + {% endif %} +

{% if list_state.count %}
diff --git a/django/core/pagination.py b/django/core/pagination.py index db6fdcd14..344676764 100644 --- a/django/core/pagination.py +++ b/django/core/pagination.py @@ -12,9 +12,9 @@ SORT_BY_FILTERS = defaultdict( lambda: "Sort by: Relevance", # default sort by relevance { - "-first_published_at": "Sort by: Publish date: newest", - "first_published_at": "Sort by: Publish date: oldest", - "-last_modified": "Sort by: Recently Modified", + "-first_published_at": "Sort by: Recently published", + "first_published_at": "Sort by: Earliest published", + "-last_modified": "Sort by: Recently modified", }, )