refactor: Remove unused playlist routes and related logic; clean up sound and stream models
This commit is contained in:
@@ -140,99 +140,3 @@ def get_status():
|
||||
)
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
|
||||
@bp.route("/history", methods=["GET"])
|
||||
@require_auth
|
||||
def get_play_history():
|
||||
"""Get recent play history."""
|
||||
try:
|
||||
page = int(request.args.get("page", 1))
|
||||
per_page = min(int(request.args.get("per_page", 50)), 100)
|
||||
offset = (page - 1) * per_page
|
||||
|
||||
recent_plays = SoundPlayed.get_recent_plays(
|
||||
limit=per_page,
|
||||
offset=offset,
|
||||
)
|
||||
|
||||
return jsonify(
|
||||
{
|
||||
"plays": [play.to_dict() for play in recent_plays],
|
||||
"page": page,
|
||||
"per_page": per_page,
|
||||
},
|
||||
)
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
|
||||
@bp.route("/my-history", methods=["GET"])
|
||||
@require_auth
|
||||
def get_my_play_history():
|
||||
"""Get current user's play history."""
|
||||
try:
|
||||
user = get_current_user()
|
||||
if not user:
|
||||
return jsonify({"error": "User not found"}), 404
|
||||
|
||||
user_id = int(user["id"])
|
||||
page = int(request.args.get("page", 1))
|
||||
per_page = min(int(request.args.get("per_page", 50)), 100)
|
||||
offset = (page - 1) * per_page
|
||||
|
||||
user_plays = SoundPlayed.get_user_plays(
|
||||
user_id=user_id,
|
||||
limit=per_page,
|
||||
offset=offset,
|
||||
)
|
||||
|
||||
return jsonify(
|
||||
{
|
||||
"plays": [play.to_dict() for play in user_plays],
|
||||
"page": page,
|
||||
"per_page": per_page,
|
||||
"user_id": user_id,
|
||||
},
|
||||
)
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
|
||||
@bp.route("/my-stats", methods=["GET"])
|
||||
@require_auth
|
||||
def get_my_stats():
|
||||
"""Get current user's play statistics."""
|
||||
try:
|
||||
user = get_current_user()
|
||||
if not user:
|
||||
return jsonify({"error": "User not found"}), 404
|
||||
|
||||
user_id = int(user["id"])
|
||||
stats = SoundPlayed.get_user_stats(user_id)
|
||||
|
||||
return jsonify(stats)
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
|
||||
@bp.route("/popular", methods=["GET"])
|
||||
@require_auth
|
||||
def get_popular_sounds():
|
||||
"""Get most popular sounds."""
|
||||
try:
|
||||
limit = min(int(request.args.get("limit", 10)), 50)
|
||||
days = request.args.get("days")
|
||||
days = int(days) if days and days.isdigit() else None
|
||||
|
||||
popular_sounds = SoundPlayed.get_popular_sounds(limit=limit, days=days)
|
||||
|
||||
return jsonify(
|
||||
{
|
||||
"popular_sounds": popular_sounds,
|
||||
"limit": limit,
|
||||
"days": days,
|
||||
},
|
||||
)
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
Reference in New Issue
Block a user