move job scheduling to DB
This commit is contained in:
@@ -8,6 +8,7 @@ from sqlalchemy.orm import selectinload
|
||||
from app.models.source import Source
|
||||
from app.models.subscription import Subscription
|
||||
from app.tasks.downloads import download_source
|
||||
from app.api.settings import get_setting_value
|
||||
|
||||
bp = Blueprint("sources", __name__)
|
||||
|
||||
@@ -100,12 +101,17 @@ async def create_source():
|
||||
if existing.scalar():
|
||||
return jsonify({"error": "Source with this platform and URL already exists"}), 409
|
||||
|
||||
# Get default check interval from database settings
|
||||
default_interval = await get_setting_value(
|
||||
session, "download.schedule_interval", 3600
|
||||
)
|
||||
|
||||
source = Source(
|
||||
subscription_id=data["subscription_id"],
|
||||
platform=data["platform"],
|
||||
url=data["url"],
|
||||
enabled=data.get("enabled", True),
|
||||
check_interval=data.get("check_interval", 3600),
|
||||
check_interval=data.get("check_interval", default_interval),
|
||||
metadata_=data.get("metadata", {}),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user