Commit 51904b4e authored by Yaowentong's avatar Yaowentong

大盘接口

parent 43aeefeb
......@@ -3,6 +3,7 @@ from datetime import datetime
from flask import jsonify, Blueprint, render_template, request
import requests
from aidso_geo.config.base_config import init_redis
from aidso_geo.utils import bh_utils
dashboard_app = Blueprint("dashboard", __name__)
......@@ -82,6 +83,56 @@ def get_req_trend():
}), 500
@dashboard_app.route("/api/third/usage/latest", methods=["GET"])
def third_usage_latest():
latest_rows = bh_utils.query_data("""
select sync_time
from geo_third_usage_snapshot
where sync_time is not null and sync_time != ''
order by sync_time desc
limit 1
""")
if latest_rows is None:
return jsonify({
"code": 500,
"msg": "query latest sync_time failed",
"data": []
}), 500
if not latest_rows:
return jsonify({
"code": 200,
"msg": "ok",
"sync_time": "",
"data": []
})
sync_time = latest_rows[0].get("sync_time")
data = bh_utils.query_data("""
select channel, pt, daily_limit, total_limit, today_used, total_used,
today_remain, total_remain, sync_time, insertime
from geo_third_usage_snapshot
where sync_time = %s
order by channel asc
""", (sync_time,))
if data is None:
return jsonify({
"code": 500,
"msg": "query third usage snapshot failed",
"sync_time": sync_time,
"data": []
}), 500
return jsonify({
"code": 200,
"msg": "ok",
"sync_time": sync_time,
"data": data
})
def normalize_date_to_datetime(value, default_time):
date_value = value.replace("T", " ").strip()[:10]
datetime.strptime(date_value, "%Y-%m-%d")
......
......@@ -331,7 +331,10 @@ def qian_report():
if platform and not isinstance(platform, list):
return fail("platform必须是数组")
req_list = get_req_id(phone, begin, end)
if not req_list:
return fail("未查询到请求记录")
try:
req_time_map = {}
req_brand_map = {}
......
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