~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
refactor: deduplicate days_map period calculation in metrics_routes (#2940)
LearningCircuitdc3e235f7433
diff --git a/src/local_deep_research/metrics/query_utils.py b/src/local_deep_research/metrics/query_utils.pyindex ae65eba103..7ae9ec59a6 100644--- a/src/local_deep_research/metrics/query_utils.py+++ b/src/local_deep_research/metrics/query_utils.py@@ -6,6 +6,17 @@ from typing import Anyfrom sqlalchemy import Column+PERIOD_DAYS_MAP = {"7d": 7, "30d": 30, "90d": 90, "365d": 365, "all": None}+++def get_period_days(period: str, default: int = 30) -> int | None:+ """Convert a period string to number of days.++ Returns None for 'all' (no time limit).+ """+ return PERIOD_DAYS_MAP.get(period, default)++def get_time_filter_condition(period: str, timestamp_column: Column) -> Any:"""Get SQLAlchemy condition for time filtering.diff --git a/src/local_deep_research/web/routes/metrics_routes.py b/src/local_deep_research/web/routes/metrics_routes.pyindex ded5c8770e..ee6aff665d 100644--- a/src/local_deep_research/web/routes/metrics_routes.py+++ b/src/local_deep_research/web/routes/metrics_routes.py@@ -20,7 +20,7 @@ from ...database.models import (from ...domain_classifier import DomainClassifier, DomainClassificationfrom ...database.session_context import get_user_db_sessionfrom ...metrics import TokenCounter-from ...metrics.query_utils import get_time_filter_condition+from ...metrics.query_utils import get_period_days, get_time_filter_conditionfrom ...metrics.search_tracker import get_search_trackerfrom ...web_search_engines.rate_limiting import get_trackerfrom ...security.decorators import require_json_body@@ -71,8 +71,7 @@ def get_rating_analytics(period="30d", research_mode="all", username=None):}# Calculate date range- days_map = {"7d": 7, "30d": 30, "90d": 90, "365d": 365, "all": None}- days = days_map.get(period, 30)+ days = get_period_days(period)with get_user_db_session(username) as session:query = session.query(ResearchRating)@@ -167,8 +166,7 @@ def get_link_analytics(period="30d", username=None):}# Calculate date range- days_map = {"7d": 7, "30d": 30, "90d": 90, "365d": 365, "all": None}- days = days_map.get(period, 30)+ days = get_period_days(period)with get_user_db_session(username) as session:# Base query@@ -539,8 +537,7 @@ def get_strategy_analytics(period="30d", username=None):}# Calculate date range- days_map = {"7d": 7, "30d": 30, "90d": 90, "365d": 365, "all": None}- days = days_map.get(period, 30)+ days = get_period_days(period)with get_user_db_session(username) as session:# Check if we have any ResearchStrategy records