~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
fix: add document count to history API for library button
LearningCircuit5e202d63f147
diff --git a/src/local_deep_research/web/routes/history_routes.py b/src/local_deep_research/web/routes/history_routes.pyindex 2b09a603c8..30afc17ad7 100644--- a/src/local_deep_research/web/routes/history_routes.py+++ b/src/local_deep_research/web/routes/history_routes.py@@ -4,6 +4,7 @@ import tracebackfrom flask import Blueprint, jsonify, make_response, session, requestfrom ...database.models import ResearchHistory+from ...database.models.library import LibraryDocumentfrom ...database.session_context import get_user_db_sessionfrom ..auth.decorators import login_requiredfrom ..models.database import (@@ -45,73 +46,81 @@ def get_history():.all())- # Convert to list of dicts- history = []- for research in results:- item = {- "id": research.id,- "title": research.title,- "query": research.query,- "mode": research.mode,- "status": research.status,- "created_at": research.created_at,- "completed_at": research.completed_at,- "duration_seconds": research.duration_seconds,- "report_path": research.report_path,- "research_meta": json.dumps(research.research_meta)- if research.research_meta- else "{}",- "progress_log": json.dumps(research.progress_log)- if research.progress_log- else "[]",- }-- # Parse research_meta as metadata for the frontend- try:- metadata = json.loads(item["research_meta"])- item["metadata"] = metadata- except:- item["metadata"] = {}-- # Ensure timestamps are in ISO format- if item["created_at"] and "T" not in item["created_at"]:- try:- # Convert to ISO format if it's not already- from dateutil import parser-- dt = parser.parse(item["created_at"])- item["created_at"] = dt.isoformat()- except Exception:- pass+ # Convert to list of dicts+ history = []+ for research in results:+ # Count documents in the library for this research+ doc_count = (+ db_session.query(LibraryDocument)+ .filter_by(research_id=research.id)+ .count()+ )++ item = {+ "id": research.id,+ "title": research.title,+ "query": research.query,+ "mode": research.mode,+ "status": research.status,+ "created_at": research.created_at,+ "completed_at": research.completed_at,+ "duration_seconds": research.duration_seconds,+ "report_path": research.report_path,+ "document_count": doc_count, # Add document count+ "research_meta": json.dumps(research.research_meta)+ if research.research_meta+ else "{}",+ "progress_log": json.dumps(research.progress_log)+ if research.progress_log+ else "[]",+ }- if item["completed_at"] and "T" not in item["completed_at"]:- try:- # Convert to ISO format if it's not already- from dateutil import parser-- dt = parser.parse(item["completed_at"])- item["completed_at"] = dt.isoformat()- except Exception:- pass-- # Recalculate duration based on timestamps if it's null but both timestamps exist- if (- item["duration_seconds"] is None- and item["created_at"]- and item["completed_at"]- ):+ # Parse research_meta as metadata for the frontendtry:- from dateutil import parser-- start_time = parser.parse(item["created_at"])- end_time = parser.parse(item["completed_at"])- item["duration_seconds"] = int(- (end_time - start_time).total_seconds()- )- except Exception as e:- print(f"Error recalculating duration: {e!s}")-- history.append(item)+ metadata = json.loads(item["research_meta"])+ item["metadata"] = metadata+ except:+ item["metadata"] = {}++ # Ensure timestamps are in ISO format+ if item["created_at"] and "T" not in item["created_at"]:+ try:+ # Convert to ISO format if it's not already+ from dateutil import parser++ dt = parser.parse(item["created_at"])+ item["created_at"] = dt.isoformat()+ except Exception:+ pass++ if item["completed_at"] and "T" not in item["completed_at"]:+ try:+ # Convert to ISO format if it's not already+ from dateutil import parser++ dt = parser.parse(item["completed_at"])+ item["completed_at"] = dt.isoformat()+ except Exception:+ pass++ # Recalculate duration based on timestamps if it's null but both timestamps exist+ if (+ item["duration_seconds"] is None+ and item["created_at"]+ and item["completed_at"]+ ):+ try:+ from dateutil import parser++ start_time = parser.parse(item["created_at"])+ end_time = parser.parse(item["completed_at"])+ item["duration_seconds"] = int(+ (end_time - start_time).total_seconds()+ )+ except Exception as e:+ print(f"Error recalculating duration: {e!s}")++ history.append(item)# Format response to match what client expectsresponse_data = {