update pay function
This commit is contained in:
13
app.py
13
app.py
@@ -7430,11 +7430,22 @@ def api_get_events():
|
||||
# 新增:关键词/全文搜索过滤(MySQL JSON)
|
||||
if search_query:
|
||||
like_pattern = f"%{search_query}%"
|
||||
|
||||
# 子查询:查找关联股票中匹配的事件ID
|
||||
stock_subquery = db.session.query(RelatedStock.event_id).filter(
|
||||
db.or_(
|
||||
RelatedStock.stock_name.ilike(like_pattern),
|
||||
RelatedStock.relation_desc.ilike(like_pattern)
|
||||
)
|
||||
).distinct()
|
||||
|
||||
# 主查询:搜索事件标题、描述、关键词或关联股票
|
||||
query = query.filter(
|
||||
db.or_(
|
||||
Event.title.ilike(like_pattern),
|
||||
Event.description.ilike(like_pattern),
|
||||
text(f"JSON_SEARCH(keywords, 'one', '%{search_query}%') IS NOT NULL")
|
||||
text(f"JSON_SEARCH(keywords, 'one', '%{search_query}%') IS NOT NULL"),
|
||||
Event.id.in_(stock_subquery)
|
||||
)
|
||||
)
|
||||
if recent_days:
|
||||
|
||||
Reference in New Issue
Block a user