def test():
"""统计用户同步分布情况"""
from pyecharts.charts import Bar, Line, Pie
from pyecharts import options as opts
from pyecharts.globals import ThemeType
from sqlalchemy.sql import func, extract
from modules.database.models import ComputerTarget
# 根据最后同步时间计算每一天的活跃量(2020-05-15是服务给数据的时间加一天)
target_date = datetime.strptime('2020-05-15', '%Y-%m-%d')
with session_maker() as session:
stats_query = session.query(
func.date_format(ComputerTarget.LastSyncTime, '%Y-%m-%d').label('date'),
func.count(ComputerTarget.TargetID).label('count')
).filter(ComputerTarget.LastSyncTime <= target_date, ComputerTarget.OSVersion == 'CMGE V0-G').order_by('date').group_by('date').all()
date_list, count_list = [], []
for item in stats_q