fix: 修改的后端代码
/api/market/statistics 接口 添加日期格式化逻辑 //api/concepts/daily-top 添加日期格式化逻辑 /api/market/heatmap 接口 已经有正确的格式化
This commit is contained in:
17
app.py
17
app.py
@@ -12232,12 +12232,19 @@ def get_market_statistics():
|
|||||||
|
|
||||||
available_dates = [str(row.TRADEDATE) for row in available_dates_result]
|
available_dates = [str(row.TRADEDATE) for row in available_dates_result]
|
||||||
|
|
||||||
|
# 格式化日期为 YYYY-MM-DD
|
||||||
|
formatted_trade_date = trade_date.strftime('%Y-%m-%d') if hasattr(trade_date, 'strftime') else str(trade_date).split(' ')[0][:10]
|
||||||
|
formatted_available_dates = [
|
||||||
|
d.strftime('%Y-%m-%d') if hasattr(d, 'strftime') else str(d).split(' ')[0][:10]
|
||||||
|
for d in [row.TRADEDATE for row in available_dates_result]
|
||||||
|
]
|
||||||
|
|
||||||
return jsonify({
|
return jsonify({
|
||||||
'success': True,
|
'success': True,
|
||||||
'trade_date': str(trade_date),
|
'trade_date': formatted_trade_date,
|
||||||
'summary': summary,
|
'summary': summary,
|
||||||
'details': list(statistics.values()),
|
'details': list(statistics.values()),
|
||||||
'available_dates': available_dates
|
'available_dates': formatted_available_dates
|
||||||
})
|
})
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -12286,10 +12293,14 @@ def get_daily_top_concepts():
|
|||||||
'stocks': concept.get('stocks', [])[:5] # 只返回前5只股票
|
'stocks': concept.get('stocks', [])[:5] # 只返回前5只股票
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# 格式化日期为 YYYY-MM-DD
|
||||||
|
price_date = data.get('price_date', '')
|
||||||
|
formatted_date = str(price_date).split(' ')[0][:10] if price_date else ''
|
||||||
|
|
||||||
return jsonify({
|
return jsonify({
|
||||||
'success': True,
|
'success': True,
|
||||||
'data': top_concepts,
|
'data': top_concepts,
|
||||||
'trade_date': data.get('price_date'),
|
'trade_date': formatted_date,
|
||||||
'count': len(top_concepts)
|
'count': len(top_concepts)
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user