@@ -135,6 +135,26 @@ def prospects_read_one(id: int = Path(..., description="ID of the prospect to re
135135 return {"meta" : meta , "data" : data }
136136
137137
138+ # PATCH endpoint to factory reset all prospects (ensure only one definition, at end of file)
139+ @router .patch ("/prospects/factoryreset" )
140+ def factory_reset_prospects () -> dict :
141+ """Reset all prospects' flag and hide fields to False."""
142+ meta = make_meta ("success" , "Factory reset all prospects (flag, hide)" )
143+ conn_gen = get_db_connection ()
144+ conn = next (conn_gen )
145+ cur = conn .cursor ()
146+ try :
147+ cur .execute ("UPDATE prospects SET flag = FALSE, hide = FALSE;" )
148+ conn .commit ()
149+ data = {"reset" : True }
150+ except Exception as e :
151+ meta = make_meta ("error" , f"Failed to factory reset: { str (e )} " )
152+ data = {"reset" : False }
153+ finally :
154+ cur .close ()
155+ conn .close ()
156+ return {"meta" : meta , "data" : data }
157+
138158# PATCH endpoint to update flag/hide
139159@router .patch ("/prospects/{id}" )
140160def update_prospect (id : int = Path (..., description = "ID of the prospect to update" ), update : ProspectUpdate = Body (...)) -> dict :
@@ -174,4 +194,26 @@ def update_prospect(id: int = Path(..., description="ID of the prospect to updat
174194 finally :
175195 cur .close ()
176196 conn .close ()
197+ return {"meta" : meta , "data" : data }
198+
199+
200+
201+ # PATCH endpoint to factory reset all prospects (ensure only one definition, at end of file)
202+ @router .patch ("/prospects/factoryreset" )
203+ def factory_reset_prospects () -> dict :
204+ """Reset all prospects' flag and hide fields to False."""
205+ meta = make_meta ("success" , "Factory reset all prospects (flag, hide)" )
206+ conn_gen = get_db_connection ()
207+ conn = next (conn_gen )
208+ cur = conn .cursor ()
209+ try :
210+ cur .execute ("UPDATE prospects SET flag = FALSE, hide = FALSE;" )
211+ conn .commit ()
212+ data = {"reset" : True }
213+ except Exception as e :
214+ meta = make_meta ("error" , f"Failed to factory reset: { str (e )} " )
215+ data = {"reset" : False }
216+ finally :
217+ cur .close ()
218+ conn .close ()
177219 return {"meta" : meta , "data" : data }
0 commit comments