chore(release): update social links and v2.2.3
- Update X/Discord links in docs and frontend dist - Dashboard: report all-time total trades - Notifications: add unread-count endpoint for badge Made-with: Cursor
This commit is contained in:
@@ -379,6 +379,13 @@ def summary():
|
||||
)
|
||||
|
||||
# Recent trades (best-effort, filtered by user_id)
|
||||
# Also compute all-time trade count for dashboard top cards.
|
||||
with get_db_connection() as db:
|
||||
cur = db.cursor()
|
||||
cur.execute("SELECT COUNT(1) AS cnt FROM qd_strategy_trades WHERE user_id = ?", (user_id,))
|
||||
total_trades_all = int((cur.fetchone() or {}).get("cnt") or 0)
|
||||
cur.close()
|
||||
|
||||
with get_db_connection() as db:
|
||||
cur = db.cursor()
|
||||
cur.execute(
|
||||
@@ -413,6 +420,8 @@ def summary():
|
||||
|
||||
# Compute performance statistics with initial capital for proper drawdown calculation
|
||||
perf_stats = _compute_performance_stats(recent_trades, initial_capital=total_initial_capital)
|
||||
# For dashboard top card: show all-time total trade count (not limited by LIMIT 500).
|
||||
perf_stats["total_trades"] = int(total_trades_all)
|
||||
|
||||
# Compute per-strategy statistics
|
||||
strategy_stats = _compute_strategy_stats(recent_trades, strategies)
|
||||
|
||||
@@ -895,6 +895,53 @@ def get_strategy_notifications():
|
||||
return jsonify({'code': 0, 'msg': str(e), 'data': {'items': []}}), 500
|
||||
|
||||
|
||||
@strategy_bp.route('/strategies/notifications/unread-count', methods=['GET'])
|
||||
@login_required
|
||||
def get_unread_notification_count():
|
||||
"""
|
||||
Get unread notification count for the current user.
|
||||
Used by frontend header badge (cap at 99+ on UI).
|
||||
"""
|
||||
try:
|
||||
user_id = g.user_id
|
||||
|
||||
with get_db_connection() as db:
|
||||
cur = db.cursor()
|
||||
cur.execute("SELECT id FROM qd_strategies_trading WHERE user_id = ?", (user_id,))
|
||||
rows = cur.fetchall() or []
|
||||
user_strategy_ids = [r.get('id') for r in rows if r.get('id')]
|
||||
cur.close()
|
||||
|
||||
where = ["is_read = 0"]
|
||||
args = []
|
||||
|
||||
if user_strategy_ids:
|
||||
placeholders = ",".join(["?"] * len(user_strategy_ids))
|
||||
where.append(f"(strategy_id IN ({placeholders}) OR (strategy_id IS NULL AND user_id = ?))")
|
||||
args.extend(user_strategy_ids)
|
||||
args.append(user_id)
|
||||
else:
|
||||
where.append("strategy_id IS NULL AND user_id = ?")
|
||||
args.append(user_id)
|
||||
|
||||
where_sql = "WHERE " + " AND ".join(where)
|
||||
|
||||
with get_db_connection() as db:
|
||||
cur = db.cursor()
|
||||
cur.execute(
|
||||
f"SELECT COUNT(1) AS cnt FROM qd_strategy_notifications {where_sql}",
|
||||
tuple(args),
|
||||
)
|
||||
cnt = int((cur.fetchone() or {}).get("cnt") or 0)
|
||||
cur.close()
|
||||
|
||||
return jsonify({'code': 1, 'msg': 'success', 'data': {'unread': cnt}})
|
||||
except Exception as e:
|
||||
logger.error(f"get_unread_notification_count failed: {str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
return jsonify({'code': 0, 'msg': str(e), 'data': {'unread': 0}}), 500
|
||||
|
||||
|
||||
@strategy_bp.route('/strategies/notifications/read', methods=['POST'])
|
||||
@login_required
|
||||
def mark_notification_read():
|
||||
|
||||
Reference in New Issue
Block a user