feat: Add MicroDAO Dashboard with activity feed and statistics
- Add microdao_activity table for news/updates/events - Add statistics columns to microdaos table - Implement dashboard API endpoints - Create UI components (HeaderCard, ActivitySection, TeamSection) - Add seed data for DAARION DAO - Update backend models and repositories - Add frontend types and API client
This commit is contained in:
@@ -4248,8 +4248,13 @@ async def get_microdao_dashboard(slug: str) -> dict:
|
||||
# Конвертувати citizens в PublicCitizenSummary
|
||||
citizen_summaries = []
|
||||
for citizen in citizens:
|
||||
# Переконатися що slug не None
|
||||
slug = citizen.get("slug")
|
||||
if not slug:
|
||||
continue # Пропустити громадян без slug
|
||||
|
||||
citizen_summaries.append({
|
||||
"slug": citizen.get("slug"),
|
||||
"slug": slug,
|
||||
"display_name": citizen["display_name"],
|
||||
"public_title": citizen.get("public_title"),
|
||||
"public_tagline": citizen.get("public_tagline"),
|
||||
@@ -4257,7 +4262,7 @@ async def get_microdao_dashboard(slug: str) -> dict:
|
||||
"kind": citizen.get("kind"),
|
||||
"district": citizen.get("district"),
|
||||
"primary_room_slug": citizen.get("primary_room_slug"),
|
||||
"public_skills": citizen.get("public_skills", []),
|
||||
"public_skills": list(citizen.get("public_skills", [])) if citizen.get("public_skills") else [],
|
||||
"online_status": citizen.get("status", "unknown"),
|
||||
"status": citizen.get("status"),
|
||||
"node_id": citizen.get("node_id"),
|
||||
@@ -4268,15 +4273,20 @@ async def get_microdao_dashboard(slug: str) -> dict:
|
||||
# Конвертувати activity в MicrodaoActivity
|
||||
activity_list = []
|
||||
for act in activity:
|
||||
# Конвертувати UUID в string, якщо потрібно
|
||||
author_id = act.get("author_agent_id")
|
||||
if author_id:
|
||||
author_id = str(author_id) if not isinstance(author_id, str) else author_id
|
||||
|
||||
activity_list.append({
|
||||
"id": str(act["id"]),
|
||||
"microdao_slug": act["microdao_slug"],
|
||||
"kind": act["kind"],
|
||||
"title": act.get("title"),
|
||||
"body": act["body"],
|
||||
"author_agent_id": str(act["author_agent_id"]) if act.get("author_agent_id") else None,
|
||||
"author_agent_id": author_id,
|
||||
"author_name": act.get("author_name"),
|
||||
"created_at": act["created_at"]
|
||||
"created_at": act["created_at"].isoformat() if hasattr(act["created_at"], "isoformat") else str(act["created_at"])
|
||||
})
|
||||
|
||||
# Створити MicrodaoSummary
|
||||
@@ -4305,11 +4315,17 @@ async def get_microdao_dashboard(slug: str) -> dict:
|
||||
}
|
||||
|
||||
# Створити stats
|
||||
last_update = microdao.get("updated_at")
|
||||
if last_update and hasattr(last_update, "isoformat"):
|
||||
last_update = last_update.isoformat()
|
||||
elif last_update:
|
||||
last_update = str(last_update)
|
||||
|
||||
stats = {
|
||||
"rooms_count": rooms_count,
|
||||
"citizens_count": citizens_count,
|
||||
"agents_count": agents_count,
|
||||
"last_update_at": microdao.get("updated_at")
|
||||
"last_update_at": last_update
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user