Files
flowdeck/app/routers/dashboard.py
T
bruno 69803c4c4a
CI / test (push) Failing after 4s
CI / lint (push) Failing after 4s
fix: remove duplicate projects from dashboard
Gitea's /api/v1/user/repos already includes all org repos the user
has access to. Fetching org repos separately added duplicates.
Removed the redundant org-repo loop from dashboard and /api/projects.
Also fixed template to use repo.owner.login instead of _org hack.
2026-07-08 09:30:33 -04:00

50 lines
1.5 KiB
Python

"""FlowDeck — Dashboard: liste des projets Gitea."""
from __future__ import annotations
import logging
from fastapi import APIRouter, Request, HTTPException, Query
from fastapi.responses import HTMLResponse
from app.services.gitea_client import gitea
logger = logging.getLogger(__name__)
router = APIRouter(tags=["dashboard"])
@router.get("/", response_class=HTMLResponse)
async def dashboard(
request: Request,
search: str = Query(default=""),
show_archived: bool = Query(default=False),
):
"""Dashboard: liste tous les projets Gitea (user + orgs)."""
try:
# User repos already includes all accessible org repos in Gitea
repos = await gitea.get_user_repos(page=1, limit=50)
# Filter
if search:
q = search.lower()
repos = [r for r in repos if q in r.get("full_name", "").lower() or q in (r.get("description") or "").lower()]
if not show_archived:
repos = [r for r in repos if not r.get("archived", False)]
# Sort by updated_at desc
repos.sort(key=lambda r: r.get("updated_at", ""), reverse=True)
except Exception as e:
logger.error("Dashboard error: %s", e)
repos = []
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader("app/templates"))
template = env.get_template("dashboard.html")
return template.render(
request=request,
repos=repos,
search=search,
show_archived=show_archived,
)