feat: Wave 2 - API org isolation + factory.html + insights.html
- Add org_id auto-population to articles.py, publishing.py, metrics.py - Add org_id filtering to search_rankings.py geo endpoints - Add org_id to calendar.py create/update/delete endpoints - Add org_id to tasks.py create endpoints - Create factory.html content pipeline page (3-tab: 待创作/进行中/待审查) - Create insights.html analytics page (4-tab: 概览/搜索排名/GEO/平台对比)
This commit is contained in:
@@ -86,7 +86,10 @@ def get_geo_overview(
|
||||
"""GEO 概览 — AI 搜索引用 + 就绪度评分"""
|
||||
cutoff = datetime.now(timezone.utc) - timedelta(days=days)
|
||||
|
||||
base = db.query(SearchRanking).filter(SearchRanking.checked_at >= cutoff)
|
||||
# Filter geo checks by org via articles
|
||||
base = db.query(SearchRanking)
|
||||
base = _apply_org_filter(base, current_user, db)
|
||||
base = base.filter(SearchRanking.checked_at >= cutoff)
|
||||
total_geo = base.filter(SearchRanking.search_engine == "geo").count()
|
||||
total_cited = base.filter(
|
||||
SearchRanking.search_engine == "geo",
|
||||
@@ -138,7 +141,14 @@ def get_geo_readiness_scores(
|
||||
):
|
||||
"""获取 GEO 就绪度评分列表"""
|
||||
cutoff = datetime.now(timezone.utc) - timedelta(days=days)
|
||||
scores = db.query(GeoReadinessScore).filter(
|
||||
# Join via articles to filter by org
|
||||
scores_query = db.query(GeoReadinessScore).join(
|
||||
ArticleModel, GeoReadinessScore.article_id == ArticleModel.id, isouter=True
|
||||
)
|
||||
of = org_filter(current_user, ArticleModel)
|
||||
if of is not True:
|
||||
scores_query = scores_query.filter(of)
|
||||
scores = scores_query.filter(
|
||||
GeoReadinessScore.checked_at >= cutoff
|
||||
).order_by(desc(GeoReadinessScore.checked_at)).limit(limit).all()
|
||||
return {"ok": True, "data": [s.to_dict() for s in scores]}
|
||||
|
||||
Reference in New Issue
Block a user