Improved UI
This commit is contained in:
14
handler.py
14
handler.py
@@ -157,6 +157,7 @@ class ImageSwipeHandler(BaseHTTPRequestHandler):
|
||||
search_keywords = [kw.strip() for kw in search_keywords_str.split(',') if kw.strip()]
|
||||
actions_str = query_params.get("actions", ["Unactioned"])[0]
|
||||
actions = [a.strip() for a in actions_str.split(',') if a.strip()]
|
||||
sort_order = query_params.get("sort", ["random"])[0] # Get sort order parameter
|
||||
|
||||
conn = sqlite3.connect(DB_PATH)
|
||||
conn.row_factory = sqlite3.Row # Important to access columns by name
|
||||
@@ -209,6 +210,12 @@ class ImageSwipeHandler(BaseHTTPRequestHandler):
|
||||
if where_clauses:
|
||||
query += " WHERE " + " AND ".join(where_clauses)
|
||||
|
||||
# Add sorting based on sort_order
|
||||
if sort_order == "oldest":
|
||||
query += " ORDER BY meta.creation_date ASC"
|
||||
elif sort_order == "newest":
|
||||
query += " ORDER BY meta.creation_date DESC"
|
||||
|
||||
cur.execute(query, params)
|
||||
rows = cur.fetchall()
|
||||
conn.close()
|
||||
@@ -217,7 +224,12 @@ class ImageSwipeHandler(BaseHTTPRequestHandler):
|
||||
self._json_response({"message": "No more images available for this filter."})
|
||||
return
|
||||
|
||||
row = random.choice(rows)
|
||||
# For random order, select a random row from the results
|
||||
if sort_order == "random":
|
||||
row = random.choice(rows)
|
||||
else:
|
||||
# For oldest/newest, use the first row in the sorted results
|
||||
row = rows[0]
|
||||
# Convert row to a dictionary for easier access
|
||||
row_dict = dict(row)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user