添加daily report生成

This commit is contained in:
pengtao 2019-10-22 15:16:35 +08:00
parent b712a04fb4
commit b4d05e25cb
2 changed files with 11 additions and 10 deletions

View File

@ -2,7 +2,7 @@
from __future__ import absolute_import from __future__ import absolute_import
from ops.mtga import GetTgaConfig, FromTga from ops.mtga import GetTgaConfig, FromTga
import os import os
from flask import Flask, render_template, request from flask import Flask, render_template, request, jsonify
from flask_mail import Mail, Message from flask_mail import Mail, Message
from threading import Thread from threading import Thread
from collections import defaultdict from collections import defaultdict
@ -42,7 +42,8 @@ def send_dailyreport():
gameid = request.args.get('gameid') gameid = request.args.get('gameid')
channelid = request.args.get('channelid') channelid = request.args.get('channelid')
day = request.args.get('day') day = request.args.get('day')
if not (gameid and channelid and day):
return jsonify("PLS input arfs")
rp = Report(gameid, channelid, day) rp = Report(gameid, channelid, day)
data = rp.run() data = rp.run()
data[gameid] = gameid data[gameid] = gameid
@ -54,7 +55,7 @@ def send_dailyreport():
thread = Thread(target=send_async_email, args=[app, msg]) thread = Thread(target=send_async_email, args=[app, msg])
thread.start() thread.start()
return '<h1>邮件发送成功</h1>' return jsonify("邮件发送成功")
class Report: class Report:

View File

@ -7,7 +7,7 @@
<body> <body>
<h1>学生表</h1> <h1>学生表</h1>
<h2>游戏ID{{ data.get(gameid) }}</h2>> <h2>游戏ID{{% data.get(gameid) %}}</h2>>
<h2>渠道ID{{ data.get('channelid') }}</h2>> <h2>渠道ID{{ data.get('channelid') }}</h2>>
<h2>日期:{{ data.get(day) }}</h2> <h2>日期:{{ data.get(day) }}</h2>
<h1>总表</h1>> <h1>总表</h1>>
@ -23,9 +23,9 @@
<td>插屏显示</td> <td>插屏显示</td>
</tr> </tr>
</body> </body>
{ % for item in data.get('all') % } {% for item in data.get('all') %}
<th>{{ item }}</th> <th>{{ item }}</th>
{ % endfor % } {% endfor %}
<h1>导入数据:</h1>> <h1>导入数据:</h1>>
<tr> <tr>
@ -56,13 +56,13 @@
<td>跳转人数</td> <td>跳转人数</td>
</tr> </tr>
{ % for line in data.get('output') % } {% for line in data.get('output') %}
<tr> <tr>
{ % for item in line % } {% for item in line %}
<th>{{ item }}</th> <th>{{ item }}</th>
{ % endfor % } {% endfor %}
</tr> </tr>
{ % endfor % } {% endfor %}
</body> </body>
</html> </html>