Commit bb703b73 authored by Yaowentong's avatar Yaowentong

修复

parent 56367639
from flask import jsonify,Blueprint,render_template
from datetime import datetime
from flask import jsonify, Blueprint, render_template, request
import requests
from aidso_geo.config.base_config import init_redis
dashboard_app = Blueprint("dashboard", __name__)
redis_client = init_redis()
@dashboard_app.route("/api/queue/status", methods=["GET"])
def queue_status():
data = {}
......@@ -29,3 +33,56 @@ def queue_status():
@dashboard_app.route("/queue/monitor", methods=["GET"])
def queue_monitor_page():
return render_template("queue_monitor.html")
@dashboard_app.route("/api/queue/platformStats", methods=["GET"])
def get_req_trend():
begin = request.args.get("begin", "").strip()
end = request.args.get("end", "").strip()
if not begin or not end:
return jsonify({
"code": 400,
"msg": "begin and end are required",
"data": []
}), 400
try:
params = {
"begin": normalize_date_to_datetime(begin, "00:00:00"),
"end": normalize_date_to_datetime(end, "23:59:59"),
}
begin_time = datetime.strptime(params["begin"], "%Y-%m-%d %H:%M:%S")
end_time = datetime.strptime(params["end"], "%Y-%m-%d %H:%M:%S")
if begin_time > end_time:
return jsonify({
"code": 400,
"msg": "begin must be earlier than end",
"data": []
}), 400
except ValueError:
return jsonify({
"code": 400,
"msg": "begin and end must be YYYY-MM-DD",
"data": []
}), 400
url = "https://openapi.aidso.com/openapi/ywt/platformStats"
try:
response = requests.get(url, params=params, timeout=300)
response.raise_for_status()
return jsonify(response.json())
except (requests.RequestException, ValueError) as e:
return jsonify({
"code": 500,
"msg": f"platformStats request failed: {e}",
"data": []
}), 500
def normalize_date_to_datetime(value, default_time):
date_value = value.replace("T", " ").strip()[:10]
datetime.strptime(date_value, "%Y-%m-%d")
return f"{date_value} {default_time}"
This diff is collapsed.
......@@ -1625,14 +1625,14 @@ def platform_process(data):
response_content = None
# #——————————————###################
#——————————————###################
# has_original = check_file_in_tos(original_path)
# has_context = check_file_in_tos(context_path)
# # 重新跑逻辑 当俩个都有走下面
# if has_original and has_context:
# process_func = PLATFORM_PROCESS_MAP.get(platform)
# if process_func:
# _, _, _, _, response_content, _ = process_func(original_path)
# _, _, _, _, response_content, _ = process_func(data)
# # 2. 只有 context:直接读 context
# elif has_context:
# response_content = tos_utils.get_string_from_tos(context_path)
......@@ -1641,16 +1641,18 @@ def platform_process(data):
# elif has_original:
# process_func = PLATFORM_PROCESS_MAP.get(platform)
# if process_func:
# _, _, _, _, response_content, _ = process_func(original_path)
# #——————————————###################
# _, _, _, _, response_content, _ = process_func(data)
#——————————————###################
#-------------
if check_file_in_tos(context_path):
response_content = tos_utils.get_string_from_tos(context_path)
else:
process_func = PLATFORM_PROCESS_MAP.get(platform)
if process_func:
_, _, _, _, response_content, _ = process_func(data)
#-------------
if response_content:
result_v2(response_content, data)
else:
......
......@@ -262,10 +262,7 @@ if __name__ == '__main__':
i['keywords'] = json.loads(i.get('keywords'))
if i.get('productWordsMap'):
i['productWordsMap'] = json.loads(i.get('productWordsMap'))
type_t = i.get('type')
# type_t = 'batch'
# return task_send_queue(i,type_t)
return qianwen_android_process_original_data(i)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment