diff --git a/app/analysis_helpers.py b/app/analysis_helpers.py index c205e5b..33c599b 100644 --- a/app/analysis_helpers.py +++ b/app/analysis_helpers.py @@ -67,10 +67,10 @@ def get_toxicity_trend(session: Session, weeks: int = 12) -> list[dict]: JOIN toxicity_scores ts ON ts.status_id = s.id WHERE s.created_at >= NOW() - INTERVAL '{weeks} weeks' GROUP BY week - ORDER BY week DESC + ORDER BY week ASC """)) - return [{"week": r[0], "avg_toxicity": float(r[1]) if r[1] else 0.0, "flagged_statuses": r[2]} for r in result] + return [{"week": r[0], "avg_toxicity": float(r[1]) if r[1] else 0.0, "flagged_posts": r[2], "flagged_mentions": 0} for r in result] def get_category_averages(session: Session) -> dict: @@ -232,11 +232,15 @@ def get_flagged_content( items.append({ "id": r[0], "status_id": r[1], + "item_id": r[1], # Template compatibility "content": r[2], "text_content": r[3], + "text": r[3] or r[2], # Template compatibility "created_at": r[4], "url": r[5], "status_type": r[6], + "item_type": r[6], # Template compatibility: post, reply, mention + "source_type": "status", # Template compatibility "author_username": r[7], "author_instance": r[8], "author_handle": f"@{r[7]}@{r[8]}",