()
return jsonify({'msg': '恢复成功', 'status': 1, 'data': _d})
改变用户状态
改变用户状态
改变用户状态
def msg_user():
    """ 改变用户状态 """
    now = datetime.now()
    _d = {'other_data': {'project_num': Project.query.count(),
                         'case_num': Case.query.count(),
                         'api_num': ApiMsg.query.count(),
                         'task_num': Task.query.count(),
                         'report_num': Report.query.count(),
                         'config_num': Config.query.count(), },
          'time_data': []}

    for num in range(7):
        _q = Logs.query.filter(
            and_(now - timedelta(days=num - 1, seconds=now.second, microseconds=now.microsecond, milliseconds=0,
                                 minutes=now.minute, hours=now.hour, weeks=0) > Logs.created_time,
                 Logs.created_time >= now - timedelta(days=num, seconds=now.second, microseconds=now.microsecond,
                                                      milliseconds=0, minutes=now.minute, hours=now.hour, weeks=0)))
        a = _q.with_entities(Logs.ip).distinct().all()
        a2 = _q.with_entities(Logs.url).distinct().all()
        t = now - timedelta(days=num)
        _d['time_data'].insert(0, {'日期': t.strftime('%Y-%m-%d'), '访问人数': len(a), '阅读次数': len(a2)})
    return jsonify({'msg': '恢复成功', 'status': 1, 'data': _d})
def msg_user ( ) : now = datetime . now ( ) _d = { 'other_data' : { 'project_num' : Project . query . count ( ) , 'case_num' : Case . query . count ( ) , 'api_num' : ApiMsg . query . count ( ) , 'task_num' : Task . query . count ( ) , 'report_num' : Report . query . count ( ) , 'config_num' : Config . query . count ( ) , } , 'time_data' : [ ] } for num in range ( 7 ) : _q = Logs . query . filter ( and_ ( now - timedelta ( days = num - 1 , seconds = now . second , microseconds = now . microsecond , milliseconds = 0 , minutes = now . minute , hours = now . hour , weeks = 0 ) > Logs . created_time , Logs . created_time >= now - timedelta ( days = num , seconds = now . second , microseconds = now . microsecond , milliseconds = 0 , minutes = now . minute , hours = now . hour , weeks = 0 ) ) ) a = _q . with_entities ( Logs . ip ) . distinct ( ) . all ( ) a2 = _q . with_entities ( Logs . url ) . distinct ( ) . all ( ) t = now - timedelta ( days = num ) _d [ 'time_data' ] . insert ( 0 , { '日期': t. s r f time('%Y - %m-%d'), ' 访 问 数': len(a), '阅 读 数': l e n a2)}) return jsonify ( { 'msg' : '恢复成功', 'statu s : 1, 'da t ' : _d})