Skip to content

Commit

Permalink
fix: add default value ttl when no conditions are met
Browse files Browse the repository at this point in the history
  • Loading branch information
HAEKADI committed Oct 29, 2024
1 parent d1f7b97 commit 4f19e18
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/elastic/es_search_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,14 @@ def should_cache_for_how_long(self):
"""Determines how long to cache search results based on conditions:
- 24 hours if execution time > MIN_EXECUTION_TIME
- 30 minutes if searching by SIREN/SIRET
- No caching otherwise or on error"""
- No caching (0 minutes) otherwise or on error"""
try:
query_terms = self.search_params.terms
if self.execution_time > MIN_EXECUTION_TIME:
return timedelta(hours=24)
if is_siren(query_terms) or is_siret(query_terms):
return timedelta(minutes=30)
return timedelta(minutes=0) # Default case when no conditions are met
except KeyError as error:
logging.info(f"Error getting search execution time: {error}")
return timedelta(minutes=0)
Expand Down

0 comments on commit 4f19e18

Please sign in to comment.