def get_query_open_thread(thread): query = Query() query.add_update("thread", " isClosed = 0 ") query.add_where_condition(" id = {}".format(thread)) return query
def get_query_remove_thread(thread): query = Query() query.add_update("thread", " isDeleted = 1 , posts = 0") query.add_where_condition(" id = {}".format(thread)) return query
def get_query_restore_post_for_thread(thread): query = Query() query.add_update("post", " isDeleted = 0 ") query.add_where_condition(" thread = {}".format(thread)) return query
def get_query_restore_post_for_id(post): query = Query() query.add_update("post", " isDeleted = 0 ") query.add_where_condition(" id = {}".format(post)) return query
def get_query_update_user(user, about, name): query = Query() query.add_update("user", " about = \"{}\", name = \"{}\" ".format(about, name)) query.add_where_condition(" email = \"{}\"".format(user)) return query
def get_query_restore_thread(thread): query = Query() query.add_update("thread as t", " isDeleted = 0 , posts = (" "select count(p.id) from post as p where p.thread = t.id)") query.add_where_condition(" id = {}".format(thread)) return query
def get_query_vote_thread(thread, vote): if vote == 1: column = "likes" difference = " + 1 " elif vote == -1: column = "dislikes" difference = " - 1 " else: return None query = Query() query.add_update("thread", " {} = {} + 1, points = points {}".format(column, column, difference)) query.add_where_condition(" id = {}".format(thread)) return query
def get_query_for_remove_thread(forum_id, is_del): query = Query() data = [("isDeleted", is_del)] query.add_update("thread", data) query.add_where_condition("id = \"{}\"".format(forum_id)) return query
def get_query_increment_posts(thread_id): query = Query() query.add_update("thread", "posts = posts + 1") query.add_where_condition("id = {}".format(thread_id)) return query
def get_query_update_thread(thread, message, slug): query = Query() query.add_update("thread", " message = \"{}\", slug = \"{}\" ".format(message, slug)) query.add_where_condition(" id = {}".format(thread)) return query
def get_query_update_post(post, message): query = Query() query.add_update("post", " message = \"{}\" ".format(message)) query.add_where_condition(" id = {}".format(post)) return query