added hidden posts to filter

This commit is contained in:
katboi01 2024-12-31 15:53:25 +01:00
parent 8b12ca9dae
commit 669656db22
2 changed files with 5 additions and 3 deletions

View File

@ -19,13 +19,13 @@ class Database:
api.add_resource(Archive_Query, "/Archive/Query") api.add_resource(Archive_Query, "/Archive/Query")
api.add_resource(Archive_GetPosts, "/Archive/GetPosts") api.add_resource(Archive_GetPosts, "/Archive/GetPosts")
def get_posts(self, num_posts, actions_taken = [0, 1, 2], last_id = -1, offset = 0): def get_posts(self, num_posts, actions_taken = [0, 1, 2, 3], last_id = -1, offset = 0):
num_posts = max(1, min(num_posts, 30)) num_posts = max(1, min(num_posts, 30))
where_query = "WHERE x_post_details.id NOT NULL AND x_posts.error_id = 0" where_query = "WHERE x_post_details.id NOT NULL AND x_posts.error_id = 0"
if last_id != -1: if last_id != -1:
where_query += f" AND x_posts.id < {last_id}" where_query += f" AND x_posts.id < {last_id}"
if actions_taken != [0, 1, 2]: if actions_taken != [0, 1, 2, 3]:
where_query += " AND (" + " OR ".join([f"x_posts.action_taken = {action}" for action in actions_taken]) + ")" where_query += " AND (" + " OR ".join([f"x_posts.action_taken = {action}" for action in actions_taken]) + ")"
query = f''' query = f'''

View File

@ -26,8 +26,10 @@ class Archive_GetPosts(Resource):
param.append(1) param.append(1)
if "denied" in request.args: if "denied" in request.args:
param.append(2) param.append(2)
if "hidden" in request.args:
param.append(3)
if param == []: if param == []:
param = [0,1,2] param = [0,1,2,3]
real_page = page-1 real_page = page-1
offset = real_page * count offset = real_page * count