Skip to content

Remove unusable code from app search#550

Open
samuelveigarangel wants to merge 5 commits intoscieloorg:mainfrom
samuelveigarangel:remove-unusable-code-from-search
Open

Remove unusable code from app search#550
samuelveigarangel wants to merge 5 commits intoscieloorg:mainfrom
samuelveigarangel:remove-unusable-code-from-search

Conversation

@samuelveigarangel
Copy link
Copy Markdown
Contributor

O que esse PR faz?

Remove funções e templates que não estão mais sendo utilizados

Onde a revisão poderia começar?

pelos commits

Como este poderia ser testado manualmente?

Realizar o build do projeto e acessar as páginas

Algum cenário de contexto que queira dar?

N/A

Screenshots

N/A

Quais são tickets relevantes?

N/A

Referências

N/A

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes legacy/unreferenced “app search” code paths (old Solr-based views, URL routes, templates, and helpers), leaving only the newer API endpoints used by the SearchGateway/OpenSearch-based search UI.

Changes:

  • Deleted the legacy Django views/routes for /search/, indicator detail/download endpoints, and graph endpoints.
  • Removed old search/indicator/graph templates and supporting helper modules/template tags.
  • Kept only the JSON API endpoints for search results list + filter metadata used by the current search page JS.

Reviewed changes

Copilot reviewed 22 out of 23 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
search/views.py Removes legacy imports/handlers and keeps the API views for results + filters.
search/urls.py Drops legacy page routes; keeps only /search/api/... endpoints.
search/templatetags/sizify.py Removed unused template filter library.
search/templatetags/partition.py Removed unused template filter library.
search/templates/search.html Deleted legacy Solr search page template.
search/templates/results.html Deleted legacy results partial.
search/templates/indicator/indicator_detail.html Deleted legacy indicator detail template.
search/templates/indicator/echarts/echarts_examples/indicator_graphic_evolution_example.html Deleted unused example template.
search/templates/indicator/echarts/echarts_examples/indicator_graphic_bar-label-rotation_example.html Deleted unused example template.
search/templates/indicator/echarts/bar-y-category-stack.html Deleted legacy echarts snippet.
search/templates/indicator/echarts/bar-y-category-stack.decal.html Deleted legacy echarts snippet.
search/templates/indicator/echarts/bar-y-category-stack.dark.html Deleted legacy echarts snippet.
search/templates/indicator/echarts/bar-y-category-stack.dark-decal.html Deleted legacy echarts snippet.
search/templates/indicator/abas.html Deleted legacy indicator tabs template.
search/templates/include/search_pagination.html Deleted legacy pagination include.
search/templates/include/result_doc_indicator.html Deleted legacy indicator result card.
search/templates/include/result_doc_directory.html Deleted legacy directory result card.
search/templates/include/result_doc.html Deleted legacy generic result card.
search/templates/graph/graph.html Deleted legacy graph page template.
search/templates/csv_template.txt Deleted legacy CSV export template.
search/templates/cluster.html Deleted legacy facet/cluster sidebar template.
search/graphic_data.py Removed legacy graph data helper class.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 11 to 14
urlpatterns = [
# path /
path("", views.search, name="search"),
path(
"detail/<str:indicator_slug>",
views.indicator_detail,
name="indicator_detail",
),
path(
"indicator/<str:indicator_slug>/summarized/",
views.indicator_summarized,
name="indicator_summarized",
),
path(
"indicator/<str:indicator_slug>/raw_data/",
views.indicator_raw_data,
name="indicator_raw_data",
),
path(
"graph/", views.graph, name="graph"
),
path(
"graph/json", views.graph_json, name="graph_json"
),
path(
"graph/context_facet", views.context_facet, name="context_facet"
),
path("api/search-results-list/", search_view_list, name="search_results_list"),
path("api/filters/", get_filters_for_data_source, name="get_filters_for_data_source"),
]
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

search/templatetags/sizify.py and search/templatetags/partition.py are removed in this PR, but multiple templates still {% load sizify %} / {% load partition %} (e.g., search_gateway/templates/search/search.html, indicator/templates/indicator.html, core/templates/dash/dash.html, chart/templates/chart/chart.html). Django will raise TemplateSyntaxError at render time when the library can't be loaded. Either keep these template-tag modules (possibly moving them to a shared app) or remove the {% load ... %} usages from the remaining templates.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samuelveigarangel, também seria necessário remover as chamadas aos template_tags em alguns templates. O copilot indicou onde isso ocorre.

search/views.py Outdated
from django.http import JsonResponse
from django.template.loader import render_to_string
from django.urls import reverse
from django.utils.translation import gettext as _
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gettext as _ is imported but not used in this module anymore. Please remove the unused import to avoid lint warnings and keep the file minimal.

Suggested change
from django.utils.translation import gettext as _

Copilot uses AI. Check for mistakes.
search/views.py Outdated
@@ -609,6 +43,7 @@ def search_view_list(request):
logging.exception(f"Error getting filters for index {index_name}. {e}")
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log message says "Error getting filters" but this try block is performing a document search + template render. Consider updating the message to reflect the actual operation (e.g., search/render results) to make logs actionable during incidents.

Suggested change
logging.exception(f"Error getting filters for index {index_name}. {e}")
logging.exception(f"Error searching documents or rendering results for index {index_name}. {e}")

Copilot uses AI. Check for mistakes.
Comment on lines 11 to 14
urlpatterns = [
# path /
path("", views.search, name="search"),
path(
"detail/<str:indicator_slug>",
views.indicator_detail,
name="indicator_detail",
),
path(
"indicator/<str:indicator_slug>/summarized/",
views.indicator_summarized,
name="indicator_summarized",
),
path(
"indicator/<str:indicator_slug>/raw_data/",
views.indicator_raw_data,
name="indicator_raw_data",
),
path(
"graph/", views.graph, name="graph"
),
path(
"graph/json", views.graph_json, name="graph_json"
),
path(
"graph/context_facet", views.context_facet, name="context_facet"
),
path("api/search-results-list/", search_view_list, name="search_results_list"),
path("api/filters/", get_filters_for_data_source, name="get_filters_for_data_source"),
]
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR removes the legacy /search/ and /search/indicator/<slug>/detail/ routes, but there are still references to them in the codebase (e.g., indicator/models.py builds https://ocabr.org/search/indicator/<slug>/detail/, and indicator/templates/admin/graph.html fetches /search/?q=*:*&raw=true). Unless those call sites are also removed/updated, this will introduce broken links and runtime 404s; consider either keeping redirects/stubs for backward compatibility or updating the remaining references to the new search/indicator URLs.

Copilot uses AI. Check for mistakes.
@samuelveigarangel samuelveigarangel force-pushed the remove-unusable-code-from-search branch from 51ddc14 to 6a2bdb4 Compare March 6, 2026 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants