added hidden posts to filter. added date
This commit is contained in:
parent
8b12ca9dae
commit
e7d21a90bb
|
@ -19,17 +19,17 @@ 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'''
|
||||||
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
|
LEFT JOIN x_post_details
|
||||||
ON x_posts.id = x_post_details.id
|
ON x_posts.id = x_post_details.id
|
||||||
LEFT JOIN accounts
|
LEFT JOIN accounts
|
||||||
|
@ -42,7 +42,7 @@ class Database:
|
||||||
posts = []
|
posts = []
|
||||||
if result is not None:
|
if result is not None:
|
||||||
for result in self.db.run_query(query):
|
for result in self.db.run_query(query):
|
||||||
posts.append({"id": result[0], "id_str": str(result[0]), "text": result[1], "files": result[2].split(','), "handle": result[3]})
|
posts.append({"id": result[0], "id_str": str(result[0]), "text": result[1], "files": result[2].split(','), "handle": result[3], "date": result[4]})
|
||||||
return posts
|
return posts
|
||||||
|
|
||||||
def reload_data(self):
|
def reload_data(self):
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue