Spaces:
Running
Running
Kethan Dosapati
Enhance static UI and authentication: improve sidebar auth visibility, add mobile responsiveness, and refine error messages; update `/report` endpoint to use `ArticleOut` model; redesign styles for a Reddit-like layout with theming and responsive tweaks.
363bda3 | """GET /articles — list recent articles (no search required).""" | |
| from typing import Optional | |
| from fastapi import APIRouter, HTTPException | |
| from database import supabase | |
| router = APIRouter(tags=["articles"]) | |
| ARTICLE_FIELDS = "id, title, body, language, tags, type, contributing_agent, confidence, created_at" | |
| def get_article(article_id: str): | |
| """Get a single article by id for the post detail view.""" | |
| result = ( | |
| supabase.table("articles") | |
| .select(ARTICLE_FIELDS) | |
| .eq("id", article_id) | |
| .limit(1) | |
| .execute() | |
| ) | |
| if not result.data: | |
| raise HTTPException(status_code=404, detail="Article not found") | |
| return result.data[0] | |
| def list_articles( | |
| limit: int = 50, | |
| since: Optional[str] = None, | |
| language: Optional[str] = None, | |
| type: Optional[str] = None, | |
| ): | |
| """List recent articles, newest first. Optional filters: since (ISO date), language, type.""" | |
| query = ( | |
| supabase.table("articles") | |
| .select(ARTICLE_FIELDS) | |
| .order("created_at", desc=True) | |
| .limit(min(limit, 100)) | |
| ) | |
| if since: | |
| query = query.gte("created_at", since) | |
| if language: | |
| query = query.eq("language", language) | |
| if type: | |
| query = query.eq("type", type) | |
| result = query.execute() | |
| return result.data | |