Skip to content

Commit

Permalink
Removed obsolete cache invalidation code from get_sources function(fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dryruffian committed Oct 18, 2024
1 parent dd6f0ab commit 1ca5d7f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
11 changes: 5 additions & 6 deletions api/api/controllers/search_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from api.utils import tallies
from api.utils.check_dead_links import check_dead_links
from api.utils.dead_link_mask import get_query_hash
from api.utils.text import SearchContext
from api.utils.search_context import SearchContext


# Using TYPE_CHECKING to avoid circular imports when importing types
Expand Down Expand Up @@ -460,9 +460,9 @@ def query_media(
)

result_ids = [result.identifier for result in results]
text = SearchContext.build(result_ids, origin_index)
search_context = SearchContext.build(result_ids, origin_index)

return results, page_count, result_count, text.asdict()
return results, page_count, result_count, search_context.asdict()


def tally_results(
Expand Down Expand Up @@ -535,7 +535,7 @@ def get_sources(index):
:param index: An Elasticsearch index, such as `'image'`.
:return: A dictionary mapping sources to the count of their images.`
"""
"""
source_cache_name = "sources-" + index
try:
sources = cache.get(key=source_cache_name)
Expand All @@ -546,7 +546,7 @@ def get_sources(index):
if not sources:
# Don't increase `size` without reading this issue first:
# https://github.com/elastic/elasticsearch/issues/18838
size = 100
size = 100
body = {
"size": 0,
"aggs": {
Expand Down Expand Up @@ -584,7 +584,6 @@ def get_sources(index):
return sources



def _get_result_and_page_count(
response_obj: Response, results: list[Hit] | None, page_size: int, page: int
) -> tuple[int, int]:
Expand Down
20 changes: 18 additions & 2 deletions documentation/pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1ca5d7f

Please sign in to comment.