You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Move the /prospects/search endpoint into a dedicated app/api/prospects/search.py router and register it in app/api/routes.py and app/api/prospects/__init__.py. Update prospects queries to ignore hidden records (WHERE hide IS NOT TRUE) for paginated listing, init aggregations, and single-item reads. Remove the inline search implementation from prospects.py and tidy imports. Bump package version to 2.0.4.
cur.execute('SELECT COUNT(*) FROM prospects WHERE hide IS NOT TRUE;')
134
89
row=cur.fetchone()
135
90
total=row[0] ifrowisnotNoneelse0
136
91
137
92
# Get unique titles and their counts (column is 'title')
138
-
cur.execute('SELECT title, COUNT(*) FROM prospects WHERE title IS NOT NULL GROUP BY title ORDER BY COUNT(*) DESC;')
93
+
cur.execute('SELECT title, COUNT(*) FROM prospects WHERE title IS NOT NULL AND hide IS NOT TRUE GROUP BY title ORDER BY COUNT(*) DESC;')
139
94
title_rows=cur.fetchall()
140
95
defslugify(text):
141
96
importre
@@ -151,7 +106,7 @@ def slugify(text):
151
106
total_unique_title=len(title)
152
107
153
108
# Get unique seniority and their counts (column is 'seniority')
154
-
cur.execute('SELECT seniority, COUNT(*) FROM prospects WHERE seniority IS NOT NULL GROUP BY seniority ORDER BY COUNT(*) DESC;')
109
+
cur.execute('SELECT seniority, COUNT(*) FROM prospects WHERE seniority IS NOT NULL AND hide IS NOT TRUE GROUP BY seniority ORDER BY COUNT(*) DESC;')
155
110
seniority_rows=cur.fetchall()
156
111
seniority= [
157
112
{"label": str(s[0]), "value": slugify(s[0])}
@@ -161,7 +116,7 @@ def slugify(text):
161
116
total_unique_seniority=len(seniority)
162
117
163
118
# Get unique sub_departments and their counts (column is 'sub_departments')
164
-
cur.execute('SELECT sub_departments, COUNT(*) FROM prospects WHERE sub_departments IS NOT NULL GROUP BY sub_departments ORDER BY COUNT(*) DESC;')
119
+
cur.execute('SELECT sub_departments, COUNT(*) FROM prospects WHERE sub_departments IS NOT NULL AND hide IS NOT TRUE GROUP BY sub_departments ORDER BY COUNT(*) DESC;')
165
120
sub_department_rows=cur.fetchall()
166
121
sub_departments= [
167
122
{"label": str(sd[0]), "value": slugify(sd[0])}
@@ -205,13 +160,13 @@ def slugify(text):
205
160
# endpoint: /prospects/{id}
206
161
@router.get("/prospects/{id}")
207
162
defprospects_read_one(id: int=Path(..., description="ID of the prospect to retrieve")) ->dict:
208
-
"""Read and return a single prospect document by id."""
163
+
"""Read and return a single prospect document by id, unless hidden."""
209
164
meta=make_meta("success", f"Read prospect with id {id}")
210
165
conn_gen=get_db_connection()
211
166
conn=next(conn_gen)
212
167
cur=conn.cursor()
213
168
try:
214
-
cur.execute('SELECT * FROM prospects WHERE id = %s;', (id,))
169
+
cur.execute('SELECT * FROM prospects WHERE id = %s AND hide IS NOT TRUE;', (id,))
cur.execute("SELECT * FROM prospects WHERE search_vector @@ plainto_tsquery('english', %s) AND hide IS NOT TRUE OFFSET %s LIMIT %s;", (query, offset, limit))
0 commit comments