def update_time_subscription(id_user: int, time_str: str) -> None: date_time = "{} {}".format(tomorrow_date(), time_str) date_time = datetime.datetime.strptime(date_time, "%Y-%m-%d %H:%M") db_session.query(Users).filter(Users.id_user == id_user).update( {"subscription": date_time}) db_session.commit()
def update_pr_data(name, url, text, path_image): db_session.query(PR_modul).filter(PR_modul.name == name).update({ "url": url, "text": text, "path_image": path_image })
def update_coord(id_user: int, city: str, country_cod: str, lat: float, lon: float, timezone: int) -> None: db_session.query(Users).filter(Users.id_user == id_user).update({ "city": city, "country_cod": country_cod, "lat": lat, "lon": lon, "timezone": timezone, }) db_session.commit()
def worker_sub() -> None: data = db_session.query(Users).all() for obj in data: if obj.subscription is None: continue time_sub_user = datetime.datetime.timestamp(obj.subscription) if time.time() > time_sub_user: # time.sleep(5) send_subscription_data(obj.id_user) update_time_sub(obj.id_user, obj.subscription)
def update_city_user(id_user, city): db_session.query(Users).filter(Users.id_user == id_user).update( {"city": city}) db_session.commit()
def update_country_cod(id_user: int, country_cod: str) -> None: db_session.query(Users).filter(Users.id_user == id_user).update( {"country_cod": country_cod}) db_session.commit()
def update_city(id_user: int, city: str) -> None: db_session.query(Users).filter(Users.id_user == id_user).update( {"city": city}) db_session.commit()
def get_country_cod(id_user: int) -> str: data = db_session.query(Users).filter(Users.id_user == id_user).first() if not data: return "" return data.country_cod
def dell_sub(id_user): db_session.query(Users).filter(Users.id_user == id_user).delete() db_session.commit()
def get_location_data_foo(id_user: int) -> dict: data = db_session.query(Users).filter(Users.id_user == id_user).first() data_location = data.get_data_location() return data_location
def get_data_sity_dict(id_user: int) -> dict: data = db_session.query(Users).filter(Users.id_user == id_user).first() data_sity_dict = json.loads(data.data_sity_dict.replace("'", '"')) return data_sity_dict
def update_data_sity_dict(id_user: int, data_sity_dict: dict) -> None: db_session.query(Users).filter(Users.id_user == id_user).update( {"data_sity_dict": str(data_sity_dict)}) db_session.commit()
def get_status(id_user: int) -> None: data = db_session.query(Users).filter(Users.id_user == id_user).first() if data: return data.status else: return None
def updete_status(id_user: int, status: int) -> None: db_session.query(Users).filter(Users.id_user == id_user).update( {"status": status}) db_session.commit()
def get_coord(id_user: int) -> tuple: data = db_session.query(Users).filter(Users.id_user == id_user).first() return data.lat, data.lon
def update_time_sub(id_user: int, time_sub_user: datetime) -> None: db_session.query(Users).filter(Users.id_user == id_user).update( {"subscription": time_sub_user + datetime.timedelta(hours=24)}) db_session.commit()
def chech_locate_null_foo(id_user: int) -> bool: data = db_session.query(Users).filter(Users.id_user == id_user).first() if not data: return False return data.chech_locate_null()