def static_top_five(): try: users = User.query.filter(User.status != 'Inactive').filter(User.tag_id is not None).filter(User.tag_id != '').order_by(User.tagcounter.desc()).limit(5) now = datetime.now() current_year = str(now.year) current_month = str(now.month) arr = [] if users is not None: for user in users: person_obj = {'name': user.name, 'amount': user.tagcounter} arr.append(person_obj) return jsonify({'json_arr': [arr[0], arr[1], arr[2], arr[3], arr[4]]}) except: return jsonify({'json_arr': None})
def get_all_users(): users = User.query.all() ret = {} for user in users: ret[user.index] = {} ret[user.index]['name'] = user.name ret[user.index]['tag'] = user.tag_id ret = jsonify(ret) return ret
def static_top_five(): try: users = User.query.filter(User.status != 'Inactive').filter( User.tag_id is not None).filter(User.tag_id != '').order_by( User.tagcounter.desc()).limit(5) now = datetime.now() current_year = str(now.year) current_month = str(now.month) arr = [] if users is not None: for user in users: person_obj = {'name': user.name, 'amount': user.tagcounter} arr.append(person_obj) return jsonify({'json_arr': [arr[0], arr[1], arr[2], arr[3], arr[4]]}) except: return jsonify({'json_arr': None})
def get_user_data_tag(tag_id): try: return User.query.filter_by(tag_id=tag_id).first().json() except: return jsonify({})
def last_tagin(): try: return Tagevent.query.all()[-1].json() except: return jsonify({})