feat: add Super Alpha research, management and MCP workflows
Deploy production / deploy (push) Successful in 56s
Deploy production / deploy (push) Successful in 56s
This commit is contained in:
@@ -91,27 +91,29 @@ class Business:
|
||||
else None,
|
||||
}
|
||||
|
||||
async def get_alpha_facets(self):
|
||||
async def get_alpha_facets(self, management_scope=None):
|
||||
from .schemas import AlphaFilters
|
||||
ids = list_statement(AlphaFilters(management_scope=management_scope)).with_only_columns(Alpha.id)
|
||||
result = {}
|
||||
for key in ("region", "universe", "alpha_type", "language", "status", "stage"):
|
||||
column = getattr(Alpha, key)
|
||||
result[key] = list(
|
||||
(
|
||||
await self.db.scalars(
|
||||
select(column).where(column.is_not(None)).distinct().order_by(column)
|
||||
select(column).where(column.is_not(None), Alpha.id.in_(ids)).distinct().order_by(column)
|
||||
)
|
||||
).all()
|
||||
)
|
||||
result["tags"] = list(
|
||||
(await self.db.scalars(select(ResearchTag.tag).distinct().order_by(ResearchTag.tag))).all()
|
||||
(await self.db.scalars(select(ResearchTag.tag).where(ResearchTag.alpha_id.in_(ids)).distinct().order_by(ResearchTag.tag))).all()
|
||||
)
|
||||
result["total"] = await self.db.scalar(select(func.count()).select_from(Alpha))
|
||||
result["total"] = await self.db.scalar(select(func.count()).select_from(Alpha).where(Alpha.id.in_(ids)))
|
||||
result["favorites"] = await self.db.scalar(
|
||||
select(func.count()).select_from(Research).where(Research.favorite.is_(True))
|
||||
select(func.count()).select_from(Research).where(Research.favorite.is_(True), Research.alpha_id.in_(ids))
|
||||
)
|
||||
result["last_sync"] = await self.db.scalar(select(func.max(Alpha.synced_at)))
|
||||
result["last_sync"] = await self.db.scalar(select(func.max(Alpha.synced_at)).where(Alpha.id.in_(ids)))
|
||||
result["source"] = sorted(
|
||||
{kind for kinds in (await source_kinds(self.db)).values() for kind in kinds}
|
||||
{kind for kinds in (await source_kinds(self.db, list(await self.db.scalars(ids)))).values() for kind in kinds}
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user