Skip to content
Merged
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
15 changes: 15 additions & 0 deletions app/api/routes/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,21 @@ def vectordb_products(
)


@router.get("/admin/respondents/demographics")
def admin_respondents_demographics(db: DBSession = Depends(get_db)) -> dict[str, Any]:
rows = db.execute(
select(Session.country, func.count().label("count"))
.where(Session.country.is_not(None))
.where(Session.country != "")
.group_by(Session.country)
.order_by(func.count().desc())
).all()

return {
"demographics": [{"country": row.country, "count": int(row.count)} for row in rows]
}


@router.get("/admin/respondents")
def admin_list_respondents(
page: int = 1,
Expand Down
Loading