added hidden posts to filter. added date

This commit is contained in:
katboi01 2024-12-31 15:53:25 +01:00
parent 8b12ca9dae
commit 770cf1f7c2
2 changed files with 6 additions and 4 deletions

View File

@ -19,17 +19,17 @@ class Database:
api.add_resource(Archive_Query, "/Archive/Query")
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))
where_query = "WHERE x_post_details.id NOT NULL AND x_posts.error_id = 0"
if last_id != -1:
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]) + ")"
query = f'''
SELECT x_posts.id, x_post_details.text, x_post_details.files, accounts.x_handle FROM x_posts
SELECT x_posts.id, x_post_details.text, x_post_details.files, accounts.x_handle, x_post_details.date FROM x_posts
LEFT JOIN x_post_details
ON x_posts.id = x_post_details.id
LEFT JOIN accounts

View File

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