Skip to content

~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.

refactor: Convert refresh_interval_hours to refresh_interval_minutes throughout codebase

LearningCircuit6b5bf6d22048
diff --git a/src/local_deep_research/database/models/news.py b/src/local_deep_research/database/models/news.py
index 2fc781ecf2..ebb80fe341 100644
--- a/src/local_deep_research/database/models/news.py
+++ b/src/local_deep_research/database/models/news.py
@@ -65,8 +65,9 @@ class NewsSubscription(Base):
String(20), nullable=False
) # 'search' or 'topic'
query_or_topic = Column(Text, nullable=False)
- refresh_interval_hours = Column(Integer, default=24)
- refresh_hours = Column(Integer, default=24) # Alias for compatibility
+ refresh_interval_minutes = Column(
+ Integer, default=1440
+ ) # Default 24 hours = 1440 minutes
frequency = Column(
String(50), default="daily"
) # daily, weekly, hourly, etc.
diff --git a/src/local_deep_research/defaults/default_settings.json b/src/local_deep_research/defaults/default_settings.json
index 53570457f3..f04f5ee584 100644
--- a/src/local_deep_research/defaults/default_settings.json
+++ b/src/local_deep_research/defaults/default_settings.json
@@ -4765,18 +4765,18 @@
"value": 4,
"visible": true
},
- "news.subscription.refresh_hours": {
+ "news.subscription.refresh_minutes": {
"category": "news",
- "description": "Default subscription refresh interval in hours",
+ "description": "Default subscription refresh interval in minutes",
"editable": true,
- "max_value": 48,
- "min_value": 1,
- "name": "Subscription Refresh Hours",
+ "max_value": 2880,
+ "min_value": 60,
+ "name": "Subscription Refresh Minutes",
"options": null,
- "step": 1,
+ "step": 60,
"type": "APP",
"ui_element": "number",
- "value": 6,
+ "value": 360,
"visible": true
},
"news.trending.lookback_hours": {
diff --git a/src/local_deep_research/news/api.py b/src/local_deep_research/news/api.py
index fec628c9cd..aec289b045 100644
--- a/src/local_deep_research/news/api.py
+++ b/src/local_deep_research/news/api.py
@@ -560,7 +560,7 @@ def get_subscription_history(
"user_id": subscription.user_id,
"query_or_topic": subscription.query_or_topic,
"subscription_type": subscription.subscription_type,
- "refresh_interval_hours": subscription.refresh_interval_hours,
+ "refresh_interval_minutes": subscription.refresh_interval_minutes,
"refresh_count": subscription.refresh_count or 0,
"created_at": subscription.created_at.isoformat()
if subscription.created_at
@@ -717,7 +717,7 @@ def get_subscription(subscription_id: str) -> Optional[Dict[str, Any]]:
"name": subscription.name or "",
"query_or_topic": subscription.query_or_topic,
"subscription_type": subscription.subscription_type,
- "refresh_interval_hours": subscription.refresh_interval_hours,
+ "refresh_interval_minutes": subscription.refresh_interval_minutes,
"is_active": subscription.status == "active",
"status": subscription.status,
"folder_id": subscription.folder_id,
@@ -780,7 +780,7 @@ def get_subscriptions(user_id: str) -> Dict[str, Any]:
"id": sub.id,
"query": sub.query_or_topic,
"type": sub.subscription_type,
- "refresh_hours": sub.refresh_interval_hours,
+ "refresh_minutes": sub.refresh_interval_minutes,
"created_at": sub.created_at.isoformat()
if sub.created_at
else None,
@@ -839,15 +839,15 @@ def update_subscription(
subscription.query_or_topic = data["query_or_topic"]
if "subscription_type" in data:
subscription.subscription_type = data["subscription_type"]
- if "refresh_interval_hours" in data:
- old_interval = subscription.refresh_interval_hours
- subscription.refresh_interval_hours = data[
- "refresh_interval_hours"
+ if "refresh_interval_minutes" in data:
+ old_interval = subscription.refresh_interval_minutes
+ subscription.refresh_interval_minutes = data[
+ "refresh_interval_minutes"
]
# Recalculate next_refresh if interval changed
- if old_interval != subscription.refresh_interval_hours:
+ if old_interval != subscription.refresh_interval_minutes:
subscription.next_refresh = datetime.utcnow() + timedelta(
- hours=subscription.refresh_interval_hours
+ minutes=subscription.refresh_interval_minutes
)
if "is_active" in data:
subscription.status = (
@@ -891,7 +891,7 @@ def update_subscription(
"name": subscription.name or "",
"query_or_topic": subscription.query_or_topic,
"subscription_type": subscription.subscription_type,
- "refresh_interval_hours": subscription.refresh_interval_hours,
+ "refresh_interval_minutes": subscription.refresh_interval_minutes,
"is_active": subscription.status == "active",
"status": subscription.status,
"folder_id": subscription.folder_id,
@@ -915,7 +915,7 @@ def create_subscription(
user_id: str,
query: str,
subscription_type: str = "search",
- refresh_hours: int = 4,
+ refresh_minutes: int = 240, # Default 4 hours
source_research_id: Optional[str] = None,
model_provider: Optional[str] = None,
model: Optional[str] = None,
@@ -935,7 +935,7 @@ def create_subscription(
user_id: User identifier
query: Search query or topic
subscription_type: "search" or "topic"
- refresh_hours: Refresh interval in hours
+ refresh_minutes: Refresh interval in minutes
Returns:
Dictionary with subscription details
@@ -953,7 +953,7 @@ def create_subscription(
name=name,
query_or_topic=query,
subscription_type=subscription_type,
- refresh_interval_hours=refresh_hours,
+ refresh_interval_minutes=refresh_minutes,
status="active" if is_active else "paused",
model_provider=model_provider,
model=model,
@@ -966,7 +966,8 @@ def create_subscription(
created_at=datetime.utcnow(),
updated_at=datetime.utcnow(),
last_refresh=None,
- next_refresh=datetime.utcnow() + timedelta(hours=refresh_hours),
+ next_refresh=datetime.utcnow()
+ + timedelta(minutes=refresh_minutes),
source_id=source_research_id,
)
@@ -982,7 +983,7 @@ def create_subscription(
"subscription_id": subscription.id,
"type": subscription_type,
"query": query,
- "refresh_hours": refresh_hours,
+ "refresh_minutes": refresh_minutes,
}
except Exception:
diff --git a/src/local_deep_research/news/flask_api.py b/src/local_deep_research/news/flask_api.py
index fafbf01281..4e41ab678e 100644
--- a/src/local_deep_research/news/flask_api.py
+++ b/src/local_deep_research/news/flask_api.py
@@ -94,7 +94,7 @@ def get_news_feed() -> Dict[str, Any]:
return jsonify(result)
except Exception as e:
- logger.exception(f"Error getting news feed: {e}")
+ logger.exception("Error getting news feed")
return jsonify({"error": str(e), "news_items": []}), 500
@@ -107,7 +107,7 @@ def create_subscription() -> Dict[str, Any]:
JSON body:
query: Search query or topic
subscription_type: "search" or "topic" (default: "search")
- refresh_hours: Refresh interval in hours (default: 4)
+ refresh_minutes: Refresh interval in minutes (default: 240)
"""
try:
data = request.get_json(force=True)
@@ -125,7 +125,7 @@ def create_subscription() -> Dict[str, Any]:
# Extract parameters
query = data.get("query")
subscription_type = data.get("subscription_type", "search")
- refresh_hours = data.get("refresh_hours", 4)
+ refresh_minutes = data.get("refresh_minutes", 240) # Default 4 hours
# Extract model configuration (optional)
model_provider = data.get("model_provider")
@@ -150,7 +150,7 @@ def create_subscription() -> Dict[str, Any]:
user_id=user_id,
query=query,
subscription_type=subscription_type,
- refresh_hours=refresh_hours,
+ refresh_minutes=refresh_minutes,
model_provider=model_provider,
model=model,
search_strategy=search_strategy,
@@ -168,7 +168,7 @@ def create_subscription() -> Dict[str, Any]:
except ValueError as e:
return jsonify({"error": str(e)}), 400
except Exception as e:
- logger.exception(f"Error creating subscription: {e}")
+ logger.exception("Error creating subscription")
return jsonify({"error": str(e)}), 500
@@ -211,7 +211,7 @@ def vote_on_news() -> Dict[str, Any]:
else:
return jsonify({"error": error_msg}), 400
except Exception as e:
- logger.exception(f"Error submitting vote: {e}")
+ logger.exception("Error submitting vote")
return jsonify({"error": str(e)}), 500
@@ -253,7 +253,7 @@ def submit_feedback(card_id: str) -> Dict[str, Any]:
else:
return jsonify({"error": error_msg}), 400
except Exception as e:
- logger.exception(f"Error submitting feedback: {e}")
+ logger.exception("Error submitting feedback")
return jsonify({"error": str(e)}), 500
@@ -276,7 +276,7 @@ def research_news_item(card_id: str) -> Dict[str, Any]:
return jsonify(result)
except Exception as e:
- logger.exception(f"Error researching news item: {e}")
+ logger.exception("Error researching news item")
return jsonify({"error": str(e)}), 500
@@ -297,7 +297,7 @@ def get_current_user_subscriptions() -> Dict[str, Any]:
return jsonify(result)
except Exception as e:
- logger.exception(f"Error getting subscriptions: {e}")
+ logger.exception("Error getting subscriptions")
return jsonify({"error": str(e)}), 500
@@ -315,7 +315,7 @@ def get_subscription(subscription_id: str) -> Dict[str, Any]:
return jsonify(subscription)
except Exception as e:
- logger.exception(f"Error getting subscription: {e}")
+ logger.exception("Error getting subscription")
return jsonify({"error": str(e)}), 500
@@ -339,7 +339,7 @@ def update_subscription(subscription_id: str) -> Dict[str, Any]:
field_mapping = {
"query": "query_or_topic",
"name": "name",
- "refresh_hours": "refresh_interval_hours",
+ "refresh_minutes": "refresh_interval_minutes",
"is_active": "is_active",
"folder_id": "folder_id",
"model_provider": "model_provider",
@@ -367,7 +367,7 @@ def update_subscription(subscription_id: str) -> Dict[str, Any]:
return jsonify(result)
except Exception as e:
- logger.exception(f"Error updating subscription: {e}")
+ logger.exception("Error updating subscription")
return jsonify({"error": str(e)}), 500
@@ -390,7 +390,7 @@ def delete_subscription(subscription_id: str) -> Dict[str, Any]:
return jsonify({"error": "Subscription not found"}), 404
except Exception as e:
- logger.exception(f"Error deleting subscription: {e}")
+ logger.exception("Error deleting subscription")
return jsonify({"error": str(e)}), 500
@@ -490,7 +490,7 @@ def run_subscription_now(subscription_id: str) -> Dict[str, Any]:
), response.status_code
except Exception as e:
- logger.exception(f"Error running subscription: {e}", exc_info=True)
+ logger.exception("Error running subscription")
return jsonify({"error": str(e)}), 500
@@ -505,7 +505,7 @@ def get_subscription_history(subscription_id: str) -> Dict[str, Any]:
result = api.get_subscription_history(subscription_id, limit)
return jsonify(result)
except Exception as e:
- logger.exception(f"Error getting subscription history: {e}")
+ logger.exception("Error getting subscription history")
return jsonify({"error": str(e)}), 500
@@ -528,7 +528,7 @@ def save_preferences() -> Dict[str, Any]:
return jsonify(result)
except Exception as e:
- logger.exception(f"Error saving preferences: {e}")
+ logger.exception("Error saving preferences")
return jsonify({"error": str(e)}), 500
@@ -542,7 +542,7 @@ def get_categories() -> Dict[str, Any]:
return jsonify(result)
except Exception as e:
- logger.exception(f"Error getting categories: {e}")
+ logger.exception("Error getting categories")
return jsonify({"error": str(e)}), 500
@@ -608,8 +608,8 @@ def get_scheduler_status() -> Dict[str, Any]:
:10
] # Limit to first 10 for display
]
- except Exception as e:
- logger.exception(f"Error getting APScheduler jobs: {e}")
+ except Exception:
+ logger.exception("Error getting APScheduler jobs")
status["apscheduler_job_count"] = 0
logger.info(f"Status built: {list(status.keys())}")
@@ -636,7 +636,7 @@ def get_scheduler_status() -> Dict[str, Any]:
return jsonify(status)
except Exception as e:
- logger.exception(f"Error getting scheduler status: {e}")
+ logger.exception("Error getting scheduler status")
return jsonify({"error": str(e)}), 500
@@ -676,7 +676,7 @@ def start_scheduler() -> Dict[str, Any]:
)
except Exception as e:
- logger.exception(f"Error starting scheduler: {e}")
+ logger.exception("Error starting scheduler")
return jsonify({"error": str(e)}), 500
@@ -703,7 +703,7 @@ def stop_scheduler() -> Dict[str, Any]:
return jsonify({"message": "No scheduler instance found"}), 404
except Exception as e:
- logger.exception(f"Error stopping scheduler: {e}")
+ logger.exception("Error stopping scheduler")
return jsonify({"error": str(e)}), 500
@@ -760,7 +760,7 @@ def check_subscriptions_now() -> Dict[str, Any]:
)
except Exception as e:
- logger.exception(f"Error checking subscriptions: {e}")
+ logger.exception("Error checking subscriptions")
return jsonify({"error": str(e)}), 500
@@ -801,7 +801,7 @@ def get_cleanup_status() -> Dict[str, Any]:
return jsonify(status)
except Exception as e:
- logger.exception(f"Error getting cleanup status: {e}")
+ logger.exception("Error getting cleanup status")
return jsonify({"error": str(e)}), 500
@@ -834,7 +834,7 @@ def trigger_cleanup() -> Dict[str, Any]:
)
except Exception as e:
- logger.exception(f"Error triggering cleanup: {e}")
+ logger.exception("Error triggering cleanup")
return jsonify({"error": str(e)}), 500
@@ -853,14 +853,14 @@ def get_active_users() -> Dict[str, Any]:
)
except Exception as e:
- logger.exception(f"Error getting active users: {e}")
+ logger.exception("Error getting active users")
return jsonify({"error": str(e)}), 500
-@news_api_bp.route("/scheduler/debug", methods=["GET"])
+@news_api_bp.route("/scheduler/stats", methods=["GET"])
@login_required
-def debug_scheduler() -> Dict[str, Any]:
- """Debug scheduler state."""
+def scheduler_stats() -> Dict[str, Any]:
+ """Get scheduler statistics and state."""
try:
from .subscription_manager.scheduler import get_news_scheduler
from flask import session
@@ -915,7 +915,7 @@ def debug_scheduler() -> Dict[str, Any]:
return jsonify(debug_info)
except Exception as e:
- logger.exception(f"Error in debug scheduler: {e}", exc_info=True)
+ logger.exception("Error in debug scheduler")
return jsonify({"error": str(e)}), 500
@@ -1030,7 +1030,7 @@ def check_overdue_subscriptions():
# Update subscription's last/next refresh times
sub.last_refresh = datetime.utcnow()
sub.next_refresh = datetime.utcnow() + timedelta(
- hours=sub.refresh_interval_hours
+ minutes=sub.refresh_interval_minutes
)
db.commit()
@@ -1073,7 +1073,7 @@ def check_overdue_subscriptions():
)
except Exception as e:
- logger.exception(f"Error checking overdue subscriptions: {e}")
+ logger.exception("Error checking overdue subscriptions")
return jsonify({"error": str(e)}), 500
@@ -1092,7 +1092,7 @@ def get_folders():
return jsonify([folder.to_dict() for folder in folders])
except Exception as e:
- logger.exception(f"Error getting folders: {e}")
+ logger.exception("Error getting folders")
return jsonify({"error": str(e)}), 500
@@ -1128,7 +1128,7 @@ def create_folder():
return jsonify(folder.to_dict()), 201
except Exception as e:
- logger.exception(f"Error creating folder: {e}")
+ logger.exception("Error creating folder")
return jsonify({"error": str(e)}), 500
@@ -1149,7 +1149,7 @@ def update_folder(folder_id):
return jsonify(folder.to_dict())
except Exception as e:
- logger.exception(f"Error updating folder: {e}")
+ logger.exception("Error updating folder")
return jsonify({"error": str(e)}), 500
@@ -1170,7 +1170,7 @@ def delete_folder(folder_id):
return jsonify({"status": "deleted"}), 200
except Exception as e:
- logger.exception(f"Error deleting folder: {e}")
+ logger.exception("Error deleting folder")
return jsonify({"error": str(e)}), 500
@@ -1193,7 +1193,7 @@ def get_subscriptions_organized():
return jsonify(result)
except Exception as e:
- logger.exception(f"Error getting organized subscriptions: {e}")
+ logger.exception("Error getting organized subscriptions")
return jsonify({"error": str(e)}), 500
@@ -1231,16 +1231,16 @@ def update_subscription_folder(subscription_id):
]:
setattr(sub, key, value)
- # Recalculate next_refresh if refresh_interval_hours changed
- if "refresh_interval_hours" in data:
- new_hours = data["refresh_interval_hours"]
+ # Recalculate next_refresh if refresh_interval_minutes changed
+ if "refresh_interval_minutes" in data:
+ new_minutes = data["refresh_interval_minutes"]
if sub.last_refresh:
sub.next_refresh = sub.last_refresh + timedelta(
- hours=new_hours
+ minutes=new_minutes
)
else:
sub.next_refresh = datetime.now(timezone.utc) + timedelta(
- hours=new_hours
+ minutes=new_minutes
)
logger.info(f"Recalculated next_refresh: {sub.next_refresh}")
@@ -1249,13 +1249,13 @@ def update_subscription_folder(subscription_id):
result = sub.to_dict()
logger.info(
- f"Updated subscription result: refresh_interval_hours={result.get('refresh_interval_hours')}, next_refresh={result.get('next_refresh')}"
+ f"Updated subscription result: refresh_interval_minutes={result.get('refresh_interval_minutes')}, next_refresh={result.get('next_refresh')}"
)
return jsonify(result)
# Force reload: v2
except Exception as e:
- logger.exception(f"Error updating subscription: {e}")
+ logger.exception("Error updating subscription")
return jsonify({"error": str(e)}), 500
@@ -1273,7 +1273,7 @@ def get_subscription_stats():
return jsonify(stats)
except Exception as e:
- logger.exception(f"Error getting stats: {e}")
+ logger.exception("Error getting stats")
return jsonify({"error": str(e)}), 500
@@ -1328,7 +1328,7 @@ def get_search_history():
)
except Exception as e:
- logger.exception(f"Error getting search history: {e}")
+ logger.exception("Error getting search history")
return jsonify({"error": str(e)}), 500
@@ -1370,7 +1370,7 @@ def add_search_history():
return jsonify({"status": "success", "id": search_history.id})
except Exception as e:
- logger.exception(f"Error adding search history: {e}")
+ logger.exception("Error adding search history")
return jsonify({"error": str(e)}), 500
@@ -1402,7 +1402,7 @@ def clear_search_history():
return jsonify({"status": "success"})
except Exception as e:
- logger.exception(f"Error clearing search history: {e}")
+ logger.exception("Error clearing search history")
return jsonify({"error": str(e)}), 500
@@ -1414,5 +1414,5 @@ def debug_database():
result = api.debug_research_items(user_id)
return jsonify(result)
except Exception as e:
- logger.exception(f"Error in debug endpoint: {e}")
+ logger.exception("Error in debug endpoint")
return jsonify({"error": str(e)}), 500
diff --git a/src/local_deep_research/news/folder_manager.py b/src/local_deep_research/news/folder_manager.py
index 275a735916..68fdb78c14 100644
--- a/src/local_deep_research/news/folder_manager.py
+++ b/src/local_deep_research/news/folder_manager.py
@@ -132,23 +132,25 @@ class FolderManager:
if hasattr(sub, key) and key not in ["id", "created_at"]:
setattr(sub, key, value)
- # Recalculate next_refresh if refresh_interval_hours changed
- if "refresh_interval_hours" in kwargs:
+ # Recalculate next_refresh if refresh_interval_minutes changed
+ if "refresh_interval_minutes" in kwargs:
from datetime import timedelta
from loguru import logger
old_next = sub.next_refresh
- new_hours = kwargs["refresh_interval_hours"]
+ new_minutes = kwargs["refresh_interval_minutes"]
if sub.last_refresh:
- sub.next_refresh = sub.last_refresh + timedelta(hours=new_hours)
+ sub.next_refresh = sub.last_refresh + timedelta(
+ minutes=new_minutes
+ )
logger.info(
- f"Updated subscription {sub.id} next_refresh based on last_refresh: {sub.last_refresh} + {new_hours}h = {sub.next_refresh}"
+ f"Updated subscription {sub.id} next_refresh based on last_refresh: {sub.last_refresh} + {new_minutes}min = {sub.next_refresh}"
)
else:
# If no last_refresh, calculate from now
sub.next_refresh = datetime.now(timezone.utc) + timedelta(
- hours=new_hours
+ minutes=new_minutes
)
logger.info(
f"Updated subscription {sub.id} next_refresh from now: {sub.next_refresh}"
@@ -218,6 +220,6 @@ class FolderManager:
"next_refresh": sub.next_refresh.isoformat()
if sub.next_refresh
else None,
- "refresh_interval_hours": sub.refresh_interval_hours,
+ "refresh_interval_minutes": sub.refresh_interval_minutes,
"status": sub.status,
}
diff --git a/src/local_deep_research/news/subscription_manager/base_subscription.py b/src/local_deep_research/news/subscription_manager/base_subscription.py
index 1334288994..0ff9c25288 100644
--- a/src/local_deep_research/news/subscription_manager/base_subscription.py
+++ b/src/local_deep_research/news/subscription_manager/base_subscription.py
@@ -21,7 +21,7 @@ class BaseSubscription(ABC):
user_id: str,
source: CardSource,
query_or_topic: str,
- refresh_interval_hours: int = 4,
+ refresh_interval_minutes: int = 240, # Default 4 hours
subscription_id: Optional[str] = None,
):
"""
@@ -31,7 +31,7 @@ class BaseSubscription(ABC):
user_id: ID of the user who owns this subscription
source: Source information for tracking origin
query_or_topic: The query or topic to subscribe to
- refresh_interval_hours: How often to check for updates
+ refresh_interval_minutes: How often to check for updates in minutes
subscription_id: Optional ID, will generate if not provided
"""
self.storage = SQLSubscriptionStorage()
@@ -39,7 +39,7 @@ class BaseSubscription(ABC):
self.user_id = user_id
self.source = source
self.query_or_topic = query_or_topic
- self.refresh_interval_hours = refresh_interval_hours
+ self.refresh_interval_minutes = refresh_interval_minutes
# Timestamps
self.created_at = utc_now()
@@ -63,10 +63,10 @@ class BaseSubscription(ABC):
if self.last_refreshed is None:
# For new subscriptions, next refresh is created_at + interval
return self.created_at + timedelta(
- hours=self.refresh_interval_hours
+ minutes=self.refresh_interval_minutes
)
return self.last_refreshed + timedelta(
- hours=self.refresh_interval_hours
+ minutes=self.refresh_interval_minutes
)
def should_refresh(self) -> bool:
@@ -134,11 +134,11 @@ class BaseSubscription(ABC):
self.last_error = str(error)
# Exponential backoff for errors
- backoff_hours = min(
- self.refresh_interval_hours * (2**self.error_count),
- 24 * 7, # Max 1 week
+ backoff_minutes = min(
+ self.refresh_interval_minutes * (2**self.error_count),
+ 24 * 60 * 7, # Max 1 week in minutes
)
- self.next_refresh = utc_now() + timedelta(hours=backoff_hours)
+ self.next_refresh = utc_now() + timedelta(minutes=backoff_minutes)
logger.error(f"Subscription {self.id} refresh failed: {error}")
@@ -159,23 +159,25 @@ class BaseSubscription(ABC):
self.next_refresh = self._calculate_next_refresh()
logger.info(f"Subscription {self.id} resumed")
- def update_interval(self, new_interval_hours: int) -> None:
+ def update_interval(self, new_interval_minutes: int) -> None:
"""
Update the refresh interval.
Args:
- new_interval_hours: New interval in hours
+ new_interval_minutes: New interval in minutes
"""
- if new_interval_hours < 1:
- raise ValueError("Refresh interval must be at least 1 hour")
- if new_interval_hours > 24 * 30:
+ if new_interval_minutes < 60:
+ raise ValueError(
+ "Refresh interval must be at least 60 minutes (1 hour)"
+ )
+ if new_interval_minutes > 60 * 24 * 30:
raise ValueError("Refresh interval cannot exceed 30 days")
- self.refresh_interval_hours = new_interval_hours
+ self.refresh_interval_minutes = new_interval_minutes
self.next_refresh = self._calculate_next_refresh()
logger.info(
- f"Subscription {self.id} interval updated to {new_interval_hours} hours"
+ f"Subscription {self.id} interval updated to {new_interval_minutes} minutes"
)
def save(self) -> str:
@@ -190,7 +192,7 @@ class BaseSubscription(ABC):
"user_id": self.user_id,
"subscription_type": self.get_subscription_type(),
"query_or_topic": self.query_or_topic,
- "refresh_interval_hours": self.refresh_interval_hours,
+ "refresh_interval_minutes": self.refresh_interval_minutes,
"source_type": self.source.type,
"source_id": self.source.source_id,
"created_from": self.source.created_from,
@@ -239,7 +241,7 @@ class BaseSubscription(ABC):
if self.last_refreshed
else None,
"next_refresh": self.next_refresh.isoformat(),
- "refresh_interval_hours": self.refresh_interval_hours,
+ "refresh_interval_minutes": self.refresh_interval_minutes,
"is_active": self.is_active,
"refresh_count": self.refresh_count,
"error_count": self.error_count,
diff --git a/src/local_deep_research/news/subscription_manager/scheduler.py b/src/local_deep_research/news/subscription_manager/scheduler.py
index 141b4e2710..78a77cc526 100644
--- a/src/local_deep_research/news/subscription_manager/scheduler.py
+++ b/src/local_deep_research/news/subscription_manager/scheduler.py
@@ -122,8 +122,8 @@ class NewsScheduler:
),
}
logger.info(f"Scheduler configuration loaded: {self.config}")
- except Exception as e:
- logger.exception(f"Error loading scheduler settings: {e}")
+ except Exception:
+ logger.exception("Error loading scheduler settings")
# Keep default config
def _get_setting(self, key: str, default: Any) -> Any:
@@ -276,22 +276,8 @@ class NewsScheduler:
# Log details of each subscription
for sub in subscriptions:
- # Handle potential None or non-numeric values
- try:
- hours = (
- float(sub.refresh_interval_hours)
- if sub.refresh_interval_hours is not None
- else 24.0
- )
- refresh_minutes = int(hours * 60)
- except (TypeError, ValueError):
- logger.warning(
- f"Invalid refresh_interval_hours for subscription {sub.id}: {sub.refresh_interval_hours}, using 24 hours"
- )
- refresh_minutes = 1440 # Default to 24 hours
-
logger.debug(
- f"Subscription {sub.id}: name='{sub.name}', is_active={sub.is_active}, status='{sub.status}', refresh_interval={sub.refresh_interval_hours}h ({refresh_minutes} minutes)"
+ f"Subscription {sub.id}: name='{sub.name}', is_active={sub.is_active}, status='{sub.status}', refresh_interval={sub.refresh_interval_minutes} minutes"
)
logger.info(
@@ -315,19 +301,7 @@ class NewsScheduler:
jitter = random.randint(0, max_jitter)
# Determine trigger based on frequency
- # Convert hours to minutes - the database stores hours but we work in minutes
- try:
- hours = (
- float(sub.refresh_interval_hours)
- if sub.refresh_interval_hours is not None
- else 24.0
- )
- refresh_minutes = int(hours * 60)
- except (TypeError, ValueError):
- logger.warning(
- f"Invalid refresh_interval_hours for subscription {sub.id}: {sub.refresh_interval_hours}, using 24 hours"
- )
- refresh_minutes = 1440 # Default 24 hours = 1440 minutes
+ refresh_minutes = sub.refresh_interval_minutes
if refresh_minutes <= 60: # 60 minutes or less
# For hourly or more frequent, use interval trigger
@@ -478,14 +452,8 @@ class NewsScheduler:
# Update last/next refresh times
sub.last_refresh = datetime.utcnow()
- # Convert hours to minutes for next refresh calculation
- refresh_minutes = (
- int(sub.refresh_interval_hours * 60)
- if sub.refresh_interval_hours
- else 60
- )
sub.next_refresh = datetime.utcnow() + timedelta(
- minutes=refresh_minutes
+ minutes=sub.refresh_interval_minutes
)
db.commit()
@@ -514,20 +482,8 @@ class NewsScheduler:
job = self.scheduler.get_job(job_id)
if job and job.trigger.__class__.__name__ == "DateTrigger":
# For date triggers, reschedule
- try:
- hours = (
- float(sub.refresh_interval_hours)
- if sub.refresh_interval_hours is not None
- else 24.0
- )
- refresh_minutes = int(hours * 60)
- except (TypeError, ValueError):
- logger.warning(
- f"Invalid refresh_interval_hours for subscription {subscription_id}: {sub.refresh_interval_hours}, using 24 hours"
- )
- refresh_minutes = 1440
next_run = datetime.now() + timedelta(
- minutes=refresh_minutes,
+ minutes=sub.refresh_interval_minutes,
seconds=random.randint(
0, int(self.config.get("max_jitter_seconds", 300))
),
@@ -866,8 +822,8 @@ class NewsScheduler:
f"Stored research result {research_id} for subscription {subscription_id}"
)
- except Exception as e:
- logger.exception(f"Error storing research result: {e}")
+ except Exception:
+ logger.exception("Error storing research result")
def _run_cleanup_with_tracking(self):
"""Wrapper that tracks cleanup execution."""
@@ -890,7 +846,7 @@ class NewsScheduler:
except Exception as e:
# Track failure
self.cleanup_status["last_error"] = str(e)
- logger.exception(f"Cleanup job failed: {e}")
+ logger.exception("Cleanup job failed")
finally:
self.cleanup_status["is_running"] = False
@@ -954,8 +910,8 @@ class NewsScheduler:
id="immediate_cleanup_config_change",
)
- except Exception as e:
- logger.exception(f"Error reloading configuration: {e}")
+ except Exception:
+ logger.exception("Error reloading configuration")
def get_status(self) -> Dict[str, Any]:
"""Get scheduler status information."""
diff --git a/src/local_deep_research/news/subscription_manager/search_subscription.py b/src/local_deep_research/news/subscription_manager/search_subscription.py
index ce366e1a23..df4cbed281 100644
--- a/src/local_deep_research/news/subscription_manager/search_subscription.py
+++ b/src/local_deep_research/news/subscription_manager/search_subscription.py
@@ -22,7 +22,7 @@ class SearchSubscription(BaseSubscription):
user_id: str,
query: str,
source: Optional[CardSource] = None,
- refresh_interval_hours: int = 6,
+ refresh_interval_minutes: int = 360, # Default 6 hours
transform_to_news_query: bool = True,
subscription_id: Optional[str] = None,
):
@@ -33,7 +33,7 @@ class SearchSubscription(BaseSubscription):
user_id: ID of the user
query: The original search query
source: Source information (auto-created if not provided)
- refresh_interval_hours: How often to check for news
+ refresh_interval_minutes: How often to check for news in minutes
transform_to_news_query: Whether to add news context to query
subscription_id: Optional ID
"""
@@ -44,7 +44,7 @@ class SearchSubscription(BaseSubscription):
)
super().__init__(
- user_id, source, query, refresh_interval_hours, subscription_id
+ user_id, source, query, refresh_interval_minutes, subscription_id
)
self.original_query = query
diff --git a/src/local_deep_research/news/subscription_manager/storage.py b/src/local_deep_research/news/subscription_manager/storage.py
index b8c657b0ff..211c4969ac 100644
--- a/src/local_deep_research/news/subscription_manager/storage.py
+++ b/src/local_deep_research/news/subscription_manager/storage.py
@@ -40,10 +40,7 @@ class SQLSubscriptionStorage(SubscriptionStorage):
name=data.get("name"),
subscription_type=data["subscription_type"],
query_or_topic=data["query_or_topic"],
- refresh_interval_hours=data.get("refresh_interval_hours", 6),
- refresh_hours=data.get(
- "refresh_hours", data.get("refresh_interval_hours", 6)
- ),
+ refresh_interval_minutes=data["refresh_interval_minutes"],
frequency=data.get("frequency", "daily"),
source_type=data.get("source_type"),
source_id=data.get("source_id"),
@@ -61,7 +58,7 @@ class SQLSubscriptionStorage(SubscriptionStorage):
search_iterations=data.get("search_iterations", 3),
questions_per_iteration=data.get("questions_per_iteration", 5),
next_refresh=datetime.now(timezone.utc)
- + timedelta(hours=data.get("refresh_interval_hours", 6)),
+ + timedelta(minutes=data["refresh_interval_minutes"]),
)
session.add(subscription)
@@ -88,7 +85,7 @@ class SQLSubscriptionStorage(SubscriptionStorage):
"name": subscription.name,
"subscription_type": subscription.subscription_type,
"query_or_topic": subscription.query_or_topic,
- "refresh_interval_hours": subscription.refresh_interval_hours,
+ "refresh_interval_minutes": subscription.refresh_interval_minutes,
"created_at": subscription.created_at,
"updated_at": subscription.updated_at,
"last_refresh": subscription.last_refresh,
@@ -135,7 +132,7 @@ class SQLSubscriptionStorage(SubscriptionStorage):
# Update allowed fields
updateable_fields = [
"name",
- "refresh_interval_hours",
+ "refresh_interval_minutes",
"status",
"is_active",
"expires_at",
@@ -153,10 +150,10 @@ class SQLSubscriptionStorage(SubscriptionStorage):
setattr(subscription, field, data[field])
# Recalculate next refresh if interval changed
- if "refresh_interval_hours" in data:
+ if "refresh_interval_minutes" in data:
subscription.next_refresh = datetime.now(
timezone.utc
- ) + timedelta(hours=data["refresh_interval_hours"])
+ ) + timedelta(minutes=data["refresh_interval_minutes"])
session.commit()
return True
@@ -210,7 +207,7 @@ class SQLSubscriptionStorage(SubscriptionStorage):
"name": sub.name,
"subscription_type": sub.subscription_type,
"query_or_topic": sub.query_or_topic,
- "refresh_interval_hours": sub.refresh_interval_hours,
+ "refresh_interval_minutes": sub.refresh_interval_minutes,
"created_at": sub.created_at,
"updated_at": sub.updated_at,
"last_refresh": sub.last_refresh,
@@ -324,7 +321,7 @@ class SQLSubscriptionStorage(SubscriptionStorage):
subscription.status = SubscriptionStatus.ACTIVE
# Reset next refresh time
subscription.next_refresh = datetime.now(timezone.utc) + timedelta(
- hours=subscription.refresh_interval_hours
+ minutes=subscription.refresh_interval_minutes
)
session.commit()
return True
diff --git a/src/local_deep_research/news/subscription_manager/topic_subscription.py b/src/local_deep_research/news/subscription_manager/topic_subscription.py
index 0014cc43d5..30cb17bdf8 100644
--- a/src/local_deep_research/news/subscription_manager/topic_subscription.py
+++ b/src/local_deep_research/news/subscription_manager/topic_subscription.py
@@ -22,7 +22,7 @@ class TopicSubscription(BaseSubscription):
self,
topic: str,
user_id: str,
- refresh_interval_hours: int = 4,
+ refresh_interval_minutes: int = 240, # Default 4 hours
source: Optional[CardSource] = None,
related_topics: Optional[List[str]] = None,
subscription_id: Optional[str] = None,
@@ -34,7 +34,7 @@ class TopicSubscription(BaseSubscription):
user_id: ID of the user
topic: The topic to follow
source: Source information (auto-created if not provided)
- refresh_interval_hours: How often to check for updates
+ refresh_interval_minutes: How often to check for updates in minutes
related_topics: Other topics related to this one
subscription_id: Optional ID
"""
@@ -45,7 +45,7 @@ class TopicSubscription(BaseSubscription):
)
super().__init__(
- user_id, source, topic, refresh_interval_hours, subscription_id
+ user_id, source, topic, refresh_interval_minutes, subscription_id
)
self.topic = topic
diff --git a/src/local_deep_research/web/services/research_service.py b/src/local_deep_research/web/services/research_service.py
index f1cdd1a304..ea9482fc82 100644
--- a/src/local_deep_research/web/services/research_service.py
+++ b/src/local_deep_research/web/services/research_service.py
@@ -1048,12 +1048,12 @@ def run_research_process(
# Get subscription to find refresh interval
subscription = sub_storage.get(subscription_id)
if subscription:
- refresh_hours = subscription.get(
- "refresh_hours", 4
+ refresh_minutes = subscription.get(
+ "refresh_minutes", 240
)
now = dt.now(timezone.utc)
next_refresh = now + timedelta(
- hours=refresh_hours
+ minutes=refresh_minutes
)
# Update refresh times
@@ -1281,9 +1281,13 @@ def run_research_process(
# Get subscription to find refresh interval
subscription = sub_storage.get(subscription_id)
if subscription:
- refresh_hours = subscription.get("refresh_hours", 4)
+ refresh_minutes = subscription.get(
+ "refresh_minutes", 240
+ )
now = dt.now(timezone.utc)
- next_refresh = now + timedelta(hours=refresh_hours)
+ next_refresh = now + timedelta(
+ minutes=refresh_minutes
+ )
# Update refresh times
sub_storage.update_refresh_time(
diff --git a/src/local_deep_research/web/static/js/components/subscription-manager.js b/src/local_deep_research/web/static/js/components/subscription-manager.js
index 3913f82dc9..87e747c23e 100644
--- a/src/local_deep_research/web/static/js/components/subscription-manager.js
+++ b/src/local_deep_research/web/static/js/components/subscription-manager.js
@@ -182,7 +182,7 @@ class SubscriptionManager {
<div class="flex-grow-1">
<h6 class="mb-1">${this.escapeHtml(subscription.query_or_topic)}</h6>
<div class="text-muted small">
- <span><i class="bi bi-clock"></i> Every ${subscription.refresh_interval_hours}h</span>
+ <span><i class="bi bi-clock"></i> Every ${subscription.refresh_interval_minutes} min</span>
<span class="ms-3"><i class="bi bi-arrow-clockwise"></i> Next: ${timeUntil}</span>
${subscription.folder ? `<span class="ms-3"><i class="bi bi-folder"></i> ${subscription.folder}</span>` : ''}
</div>
@@ -230,12 +230,12 @@ class SubscriptionManager {
<div class="mb-3">
<label class="form-label">Update Frequency</label>
<select class="form-select" id="edit-frequency">
- <option value="1" ${subscription.refresh_interval_hours === 1 ? 'selected' : ''}>Every hour</option>
- <option value="3" ${subscription.refresh_interval_hours === 3 ? 'selected' : ''}>Every 3 hours</option>
- <option value="6" ${subscription.refresh_interval_hours === 6 ? 'selected' : ''}>Every 6 hours</option>
- <option value="12" ${subscription.refresh_interval_hours === 12 ? 'selected' : ''}>Every 12 hours</option>
- <option value="24" ${subscription.refresh_interval_hours === 24 ? 'selected' : ''}>Daily</option>
- <option value="168" ${subscription.refresh_interval_hours === 168 ? 'selected' : ''}>Weekly</option>
+ <option value="60" ${subscription.refresh_interval_minutes === 60 ? 'selected' : ''}>Every hour</option>
+ <option value="180" ${subscription.refresh_interval_minutes === 180 ? 'selected' : ''}>Every 3 hours</option>
+ <option value="360" ${subscription.refresh_interval_minutes === 360 ? 'selected' : ''}>Every 6 hours</option>
+ <option value="720" ${subscription.refresh_interval_minutes === 720 ? 'selected' : ''}>Every 12 hours</option>
+ <option value="1440" ${subscription.refresh_interval_minutes === 1440 ? 'selected' : ''}>Daily</option>
+ <option value="10080" ${subscription.refresh_interval_minutes === 10080 ? 'selected' : ''}>Weekly</option>
</select>
</div>
<div class="mb-3">
@@ -271,7 +271,7 @@ class SubscriptionManager {
// Handle save
document.getElementById('save-subscription-edit').addEventListener('click', async () => {
const updates = {
- refresh_interval_hours: parseInt(document.getElementById('edit-frequency').value),
+ refresh_interval_minutes: parseInt(document.getElementById('edit-frequency').value),
folder: document.getElementById('edit-folder').value,
notes: document.getElementById('edit-notes').value
};
diff --git a/src/local_deep_research/web/static/js/pages/news.js b/src/local_deep_research/web/static/js/pages/news.js
index f6e4cbdfcc..4880eb7d25 100644
--- a/src/local_deep_research/web/static/js/pages/news.js
+++ b/src/local_deep_research/web/static/js/pages/news.js
@@ -424,7 +424,7 @@ async function createSubscriptionFromSearch(query, researchId) {
body: JSON.stringify({
query: query,
subscription_type: 'search',
- refresh_hours: 1,
+ refresh_minutes: 60,
metadata: {
research_id: researchId,
is_advanced_query: true
@@ -544,7 +544,7 @@ async function createSimpleSubscription(query) {
body: JSON.stringify({
query: query,
subscription_type: 'search',
- refresh_hours: 1
+ refresh_minutes: 1
})
});
@@ -1664,7 +1664,7 @@ async function showSubscriptionHistory(subscriptionId) {
</span>
<span class="stat-item">
<i class="bi bi-clock"></i>
- Every ${data.subscription.refresh_interval_hours}h
+ Every ${data.subscription.refresh_interval_minutes} min
</span>
<span class="stat-item">
<i class="bi bi-calendar"></i>
@@ -1804,7 +1804,7 @@ function hideSubscriptionModal() {
async function createSubscription() {
const type = document.querySelector('input[name="sub-type"]:checked').value;
const query = document.getElementById('sub-query').value;
- const refreshHours = document.getElementById('sub-refresh').value;
+ const refreshMinutes = document.getElementById('sub-refresh').value;
if (!query) {
showAlert('Please enter a query or topic', 'warning');
@@ -1821,7 +1821,7 @@ async function createSubscription() {
body: JSON.stringify({
query: query,
subscription_type: type,
- refresh_hours: parseInt(refreshHours)
+ refresh_minutes: parseInt(refreshMinutes)
})
});
@@ -3200,7 +3200,7 @@ async function handleNewsSubscriptionSubmit(e) {
body: JSON.stringify({
query: query,
subscription_type: 'search',
- refresh_hours: parseInt(frequency),
+ refresh_minutes: parseInt(frequency),
model_provider: modelProvider,
model: model,
search_strategy: searchStrategy
diff --git a/src/local_deep_research/web/static/js/pages/subscriptions.js b/src/local_deep_research/web/static/js/pages/subscriptions.js
index 5a853edec5..6f5150987e 100644
--- a/src/local_deep_research/web/static/js/pages/subscriptions.js
+++ b/src/local_deep_research/web/static/js/pages/subscriptions.js
@@ -103,7 +103,7 @@ async function loadSubscriptions() {
if (sub3090) {
console.log('3090 subscription data:', {
id: sub3090.id,
- refresh_hours: sub3090.refresh_hours,
+ refresh_minutes: sub3090.refresh_minutes,
next_refresh: sub3090.next_refresh,
last_refreshed: sub3090.last_refreshed
});
@@ -165,8 +165,8 @@ function createSubscriptionCard(subscription) {
const lastUpdated = subscription.last_refreshed ?
new Date(subscription.last_refreshed).toLocaleString() : 'Never';
- // Convert refresh_hours to readable format
- const refreshMinutes = subscription.refresh_hours * 60;
+ // Use refresh_minutes directly
+ const refreshMinutes = subscription.refresh_minutes;
let refreshInterval;
if (refreshMinutes === 1) {
refreshInterval = 'Every minute';
diff --git a/src/local_deep_research/web/templates/pages/news-subscription-form.html b/src/local_deep_research/web/templates/pages/news-subscription-form.html
index 1dfd756fc8..a57b9c5ad3 100644
--- a/src/local_deep_research/web/templates/pages/news-subscription-form.html
+++ b/src/local_deep_research/web/templates/pages/news-subscription-form.html
@@ -116,7 +116,7 @@
<div class="col-md-6 mb-3">
<label for="subscription-interval" class="form-label">Update Frequency (minutes)</label>
<input type="number" class="form-control" id="subscription-interval"
- min="1" step="1" value="{% if subscription %}{{ (subscription.refresh_interval_hours * 60)|int if subscription.refresh_interval_hours else 1440 }}{% else %}1440{% endif %}" required>
+ min="1" step="1" value="{% if subscription %}{{ subscription.refresh_interval_minutes|int if subscription.refresh_interval_minutes else 1440 }}{% else %}1440{% endif %}" required>
<div class="form-text">
Common values: 1 (every minute), 60 (hourly), 1440 (daily), 10080 (weekly)
<br>
@@ -511,7 +511,7 @@ document.addEventListener('DOMContentLoaded', async function() {
try {
// Initialize interval for existing subscription
- {% if subscription and subscription.refresh_interval_hours %}
+ {% if subscription and subscription.refresh_interval_minutes %}
// Already handled in the input value attribute
{% endif %}
@@ -693,7 +693,7 @@ async function handleSubscriptionSubmit(e) {
query: query,
name: name,
subscription_type: 'search',
- refresh_hours: intervalMinutes / 60, // Convert minutes to hours (can be fractional)
+ refresh_minutes: intervalMinutes, // Convert minutes to hours (can be fractional)
folder_id: folder || null,
is_active: isActive,
model_provider: provider,
@@ -894,7 +894,7 @@ async function handleCreateAndRun(event) {
query: query,
name: name,
subscription_type: 'search',
- refresh_hours: intervalMinutes / 60,
+ refresh_minutes: intervalMinutes,
folder_id: folder || null,
is_active: isActive,
model_provider: provider,
diff --git a/tests/ldr-news-dev-files/redundant-tests/test_news_api_debug.js b/tests/ldr-news-dev-files/redundant-tests/test_news_api_debug.js
index ac894d3f2c..1d926b2ee7 100644
--- a/tests/ldr-news-dev-files/redundant-tests/test_news_api_debug.js
+++ b/tests/ldr-news-dev-files/redundant-tests/test_news_api_debug.js
@@ -61,7 +61,7 @@ async function debugNewsAPI() {
user_id: 'test',
query: 'AI technology news',
subscription_type: 'search',
- refresh_hours: 1
+ refresh_minutes: 60
})
});
diff --git a/tests/ldr-news-dev-files/redundant-tests/test_news_final.js b/tests/ldr-news-dev-files/redundant-tests/test_news_final.js
index da45003c87..0ea2dfc058 100644
--- a/tests/ldr-news-dev-files/redundant-tests/test_news_final.js
+++ b/tests/ldr-news-dev-files/redundant-tests/test_news_final.js
@@ -66,7 +66,7 @@ async function testNewsFinal() {
user_id: 'final_test',
query: 'Final test subscription',
subscription_type: 'search',
- refresh_hours: 6
+ refresh_minutes: 360
})
});
const data = await response.json();
diff --git a/tests/ui_tests/news/test_scheduler_activity.js b/tests/ui_tests/news/test_scheduler_activity.js
index b5cdc51f31..fa23855fce 100644
--- a/tests/ui_tests/news/test_scheduler_activity.js
+++ b/tests/ui_tests/news/test_scheduler_activity.js
@@ -105,7 +105,7 @@ describe('News Scheduler Activity Test', function() {
},
body: JSON.stringify({
query: 'Test scheduler activity',
- refresh_hours: 1,
+ refresh_minutes: 60,
name: 'Scheduler Test Subscription'
})
});