mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-25 09:26:17 -05:00
deps: cachetools 7 and the current web-vitals API (#771)
cachetools 6 removed cachetools.func.mru_cache; the Zim search estimate cache was its only user, so it becomes an lru_cache and the pin moves to 7.2.0 with the Dependabot ignore removed. reportWebVitals still destructured the web-vitals 2.x names (getCLS, getFID, ...) which no longer exist, so it silently did nothing. Use the on* names, replace FID with INP, return the import promise, and accept any callable rather than instanceof Function. Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
c28a9e0078
commit
1c8bbf1f10
6 changed files with 50 additions and 12 deletions
|
|
@ -260,7 +260,7 @@ def search_all_zims(session: Session, search_str: str, tag_names: List[str] = No
|
|||
return all_results
|
||||
|
||||
|
||||
@cachetools.func.mru_cache(maxsize=1_000)
|
||||
@cachetools.func.lru_cache(maxsize=1_000)
|
||||
def get_estimates(search_str: str) -> List[int]:
|
||||
zims = Zims.get_all()
|
||||
estimates = [i.estimate(search_str) for i in zims]
|
||||
|
|
|
|||
|
|
@ -411,3 +411,15 @@ def test_get_custom_zims_directory(async_client, test_directory, test_wrolpi_con
|
|||
get_wrolpi_config().zims_destination = 'custom/zims'
|
||||
|
||||
assert lib.get_zim_directory() == (test_directory / 'custom/zims')
|
||||
|
||||
|
||||
def test_get_estimates_is_cached():
|
||||
"""Repeated estimates for the same search string do not re-query the Zims."""
|
||||
from unittest import mock
|
||||
from modules.zim import lib
|
||||
|
||||
lib.get_estimates.cache_clear()
|
||||
with mock.patch.object(lib.Zims, 'get_all', return_value=[]) as get_all:
|
||||
assert lib.get_estimates('cached search') == []
|
||||
assert lib.get_estimates('cached search') == []
|
||||
assert get_all.call_count == 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue