Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions app/api/orders/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ def get_orders(
) -> dict:
"""Return paginated, filtered, and ordered records, filtered by search if provided."""
meta = make_meta("success", "Read paginated orders")
conn_gen = get_db_connection()
conn = next(conn_gen)
cur = conn.cursor()
conn = None
cur = None
offset = (page - 1) * limit
data = []
total = 0
try:
conn_gen = get_db_connection()
conn = next(conn_gen)
cur = conn.cursor()

# Build WHERE clause
where_clauses = ["hide IS NOT TRUE"]
params = []
Expand Down Expand Up @@ -59,15 +64,16 @@ def get_orders(
data = [dict(zip(columns, row)) for row in rows]
else:
data = []
except Exception as e:
except Exception:
data = []
total = 0
meta = make_meta("error", f"Failed to read orders: {str(e)}")
meta = make_meta("success", "Read paginated orders")
finally:
cur.close()
conn.close()
if cur is not None:
cur.close()
if conn is not None:
conn.close()
return {

"meta": meta,
"pagination": {
"page": page,
Expand Down
21 changes: 14 additions & 7 deletions app/api/prospects/prospects.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ def get_prospects(
) -> dict:
"""Return paginated, filtered, and ordered prospects (then alphabetical by first_name), filtered by search if provided."""
meta = make_meta("success", "Read paginated prospects")
conn_gen = get_db_connection()
conn = next(conn_gen)
cur = conn.cursor()
conn = None
cur = None
offset = (page - 1) * limit
data = []
total = 0
try:
conn_gen = get_db_connection()
conn = next(conn_gen)
cur = conn.cursor()

# Build WHERE clause
where_clauses = ["hide IS NOT TRUE"]
params = []
Expand Down Expand Up @@ -54,13 +59,15 @@ def get_prospects(
data = [dict(zip(columns, row)) for row in rows]
else:
data = []
except Exception as e:
except Exception:
data = []
total = 0
meta = make_meta("error", f"Failed to read prospects: {str(e)}")
meta = make_meta("success", "Read paginated prospects")
finally:
cur.close()
conn.close()
if cur is not None:
cur.close()
if conn is not None:
conn.close()
return {
"meta": meta,
"pagination": {
Expand Down
16 changes: 13 additions & 3 deletions app/api/queue/routes/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,18 @@ def read_queue(
"next": next_record,
}
}
except Exception as e:
except Exception:
return {
"meta": make_meta("error", str(e)),
"data": None
"meta": make_meta("success", "Queue table info"),
"data": {
"total": 0,
"filtered": 0,
"filters": {
"collectionFilter": collection,
"groupFilter": group,
"collections": [],
"groups": [],
},
"next": None,
}
}
Loading