@@ -85,7 +85,7 @@ def _build_decision(unit_id: str, row: dict[str, str | None]) -> ReviewDecisionR
8585
8686
8787@router .get ("/queue" )
88- def review_queue (
88+ async def review_queue (
8989 limit : int = 20 ,
9090 offset : int = 0 ,
9191 _user : str = Depends (get_current_user ),
@@ -102,8 +102,8 @@ def review_queue(
102102 Returns:
103103 A paginated list of pending knowledge units with review metadata.
104104 """
105- items = store .pending_queue (limit = limit , offset = offset )
106- total = store .pending_count ()
105+ items = await store .pending_queue (limit = limit , offset = offset )
106+ total = await store .pending_count ()
107107 return ReviewQueueResponse (
108108 items = [
109109 ReviewItem (
@@ -121,7 +121,7 @@ def review_queue(
121121
122122
123123@router .post ("/{unit_id}/approve" )
124- def approve_unit (
124+ async def approve_unit (
125125 unit_id : str ,
126126 username : str = Depends (get_current_user ),
127127 store : RemoteStore = Depends (get_store ),
@@ -140,19 +140,19 @@ def approve_unit(
140140 HTTPException: With status 404 if the unit does not exist.
141141 HTTPException: With status 409 if the unit has already been reviewed.
142142 """
143- status = store .get_review_status (unit_id )
143+ status = await store .get_review_status (unit_id )
144144 if status is None :
145145 raise HTTPException (status_code = 404 , detail = "Knowledge unit not found" )
146146 if status ["status" ] != "pending" :
147147 raise HTTPException (status_code = 409 , detail = f"Knowledge unit already { status ['status' ]} " )
148- store .set_review_status (unit_id , "approved" , username )
149- updated = store .get_review_status (unit_id )
148+ await store .set_review_status (unit_id , "approved" , username )
149+ updated = await store .get_review_status (unit_id )
150150 assert updated is not None # Unit exists; we just wrote to it.
151151 return _build_decision (unit_id , updated )
152152
153153
154154@router .post ("/{unit_id}/reject" )
155- def reject_unit (
155+ async def reject_unit (
156156 unit_id : str ,
157157 username : str = Depends (get_current_user ),
158158 store : RemoteStore = Depends (get_store ),
@@ -171,19 +171,19 @@ def reject_unit(
171171 HTTPException: With status 404 if the unit does not exist.
172172 HTTPException: With status 409 if the unit has already been reviewed.
173173 """
174- status = store .get_review_status (unit_id )
174+ status = await store .get_review_status (unit_id )
175175 if status is None :
176176 raise HTTPException (status_code = 404 , detail = "Knowledge unit not found" )
177177 if status ["status" ] != "pending" :
178178 raise HTTPException (status_code = 409 , detail = f"Knowledge unit already { status ['status' ]} " )
179- store .set_review_status (unit_id , "rejected" , username )
180- updated = store .get_review_status (unit_id )
179+ await store .set_review_status (unit_id , "rejected" , username )
180+ updated = await store .get_review_status (unit_id )
181181 assert updated is not None # Unit exists; we just wrote to it.
182182 return _build_decision (unit_id , updated )
183183
184184
185185@router .get ("/stats" )
186- def review_stats (
186+ async def review_stats (
187187 _user : str = Depends (get_current_user ),
188188 store : RemoteStore = Depends (get_store ),
189189) -> ReviewStatsResponse :
@@ -197,24 +197,24 @@ def review_stats(
197197 Aggregated counts by status, domain distribution, confidence
198198 distribution, recent activity, and daily trend data.
199199 """
200- counts = store .counts_by_status ()
200+ counts = await store .counts_by_status ()
201201 return ReviewStatsResponse (
202202 counts = {
203203 "pending" : counts .get ("pending" , 0 ),
204204 "approved" : counts .get ("approved" , 0 ),
205205 "rejected" : counts .get ("rejected" , 0 ),
206206 },
207- domains = store .domain_counts (),
208- confidence_distribution = store .confidence_distribution (),
209- recent_activity = store .recent_activity (),
207+ domains = await store .domain_counts (),
208+ confidence_distribution = await store .confidence_distribution (),
209+ recent_activity = await store .recent_activity (),
210210 trends = TrendsResponse (
211- daily = [DailyCount (** d ) for d in store .daily_counts ()],
211+ daily = [DailyCount (** d ) for d in await store .daily_counts ()],
212212 ),
213213 )
214214
215215
216216@router .get ("/units" )
217- def list_units (
217+ async def list_units (
218218 domain : str | None = None ,
219219 confidence_min : float | None = None ,
220220 confidence_max : float | None = None ,
@@ -238,7 +238,7 @@ def list_units(
238238 Returns:
239239 List of knowledge units with review metadata.
240240 """
241- items = store .list_units (
241+ items = await store .list_units (
242242 domain = domain ,
243243 confidence_min = confidence_min ,
244244 confidence_max = confidence_max ,
@@ -257,7 +257,7 @@ def list_units(
257257
258258
259259@router .get ("/{unit_id}" )
260- def get_unit (
260+ async def get_unit (
261261 unit_id : str ,
262262 _user : str = Depends (get_current_user ),
263263 store : RemoteStore = Depends (get_store ),
@@ -275,10 +275,10 @@ def get_unit(
275275 Raises:
276276 HTTPException: With status 404 if the unit does not exist.
277277 """
278- ku = store .get_any (unit_id )
278+ ku = await store .get_any (unit_id )
279279 if ku is None :
280280 raise HTTPException (status_code = 404 , detail = "Knowledge unit not found" )
281- review = store .get_review_status (unit_id )
281+ review = await store .get_review_status (unit_id )
282282 assert review is not None # Unit exists; get_any just returned it.
283283 return ReviewItem (
284284 knowledge_unit = ku ,
0 commit comments