Skip to content

Commit 1e44188

Browse files
committed
Expose collection freshness in school bot endpoint
Add collection_updated_at and collection_book_count to the /v1/school/{id}/bot response. The chatflow uses this to warn schools with stale (>3 years old) collection data.
1 parent 0d0c17f commit 1e44188

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

app/api/schools.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,22 @@ async def get_school_bookbot_type(
224224
or their own, and which "experiments" the school has activated, if any.
225225
Used for the publicly-accessible Bookbot chat links.
226226
"""
227-
# dependency will automatically 404 if school doesn't exist
228-
return {
227+
result = {
229228
"name": school.name,
230229
"type": school.bookbot_type,
231230
"experiments": school.info["experiments"],
232231
"supporter": school.subscription is not None and school.subscription.is_active,
233232
}
234233

234+
if school.collection:
235+
result["collection_updated_at"] = school.collection.updated_at.isoformat()
236+
result["collection_book_count"] = school.collection.book_count
237+
else:
238+
result["collection_updated_at"] = None
239+
result["collection_book_count"] = 0
240+
241+
return result
242+
235243

236244
@router.get("/school/{wriveted_identifier}/bookbot", response_model=SchoolBookbotInfo)
237245
async def get_school_bookbot_info(

0 commit comments

Comments
 (0)