tuning ui and adding adaptive themeing to extension
This commit is contained in:
@@ -128,6 +128,46 @@ async def retry_download(download_id: int):
|
||||
}), 202
|
||||
|
||||
|
||||
@bp.route("/recent-activity", methods=["GET"])
|
||||
async def recent_activity():
|
||||
"""Get recent noteworthy downloads: failures and completions with new files.
|
||||
|
||||
These are downloads that warrant user attention, not routine "no new content" runs.
|
||||
Results are limited to the last 7 days by default.
|
||||
"""
|
||||
limit = min(int(request.args.get("limit", 10)), 50)
|
||||
days = int(request.args.get("days", 7))
|
||||
|
||||
from datetime import timedelta
|
||||
cutoff = datetime.utcnow() - timedelta(days=days)
|
||||
|
||||
async with current_app.db_engine.connect() as conn:
|
||||
session = AsyncSession(bind=conn)
|
||||
|
||||
# Get failed downloads OR completed with files (noteworthy activity)
|
||||
from sqlalchemy import or_
|
||||
query = select(Download).where(
|
||||
and_(
|
||||
Download.created_at >= cutoff,
|
||||
or_(
|
||||
Download.status == DownloadStatus.FAILED,
|
||||
and_(
|
||||
Download.status == DownloadStatus.COMPLETED,
|
||||
Download.file_count > 0
|
||||
)
|
||||
)
|
||||
)
|
||||
).order_by(Download.created_at.desc()).limit(limit)
|
||||
|
||||
result = await session.execute(query)
|
||||
downloads = result.scalars().all()
|
||||
|
||||
return jsonify({
|
||||
"items": [d.to_dict() for d in downloads],
|
||||
"count": len(downloads),
|
||||
})
|
||||
|
||||
|
||||
@bp.route("/stats", methods=["GET"])
|
||||
async def get_stats():
|
||||
"""Get download statistics."""
|
||||
|
||||
Reference in New Issue
Block a user