def hold_controller(): while (True): time.sleep(60 * 10) with DatabaseClient() as db: print("Making everyones hold to zero") with db_changing_lock: db.substract_hold_of_every_sub()
def load_db_from_json(addition=None): with DatabaseClient() as db: print(f"json['addition'] from POST request: {addition}") with db_changing_lock: db.load_from_json(addition) return jsonify({"status": 200, "result": True, "addition": addition})
def refresh_db(): with DatabaseClient() as db: with db_changing_lock: db.drop_table() db.create_table() return jsonify({"status": 200, "result": True})
def substract(sum=None, uuid=None, addition=None): with DatabaseClient() as db: print(f"extracted params is : {(sum, uuid)}") with db_changing_lock: db.substract_money_from_sub(uuid, sum) return jsonify({"status": 200, "result": True, "addition": addition})
def add(sum=None, uuid=None, addition=None): with DatabaseClient() as db: with db_changing_lock: db.add_money_to_sub(uuid, sum) return jsonify({"status": 200, "result": True, "addition": addition})
def user_from_json(uuid=None, addition=None): with DatabaseClient() as db: addition = db.select_user_by_uuid(uuid).dict_for_json() return jsonify({"status": 200, "result": True, "addition": addition})
def users(): with DatabaseClient() as db: return jsonify({"addition": db.dump_users_to_dict_for_json()})