caelum0x 94bf6dbf48 feat(ritgram): make search/trending/repo surfaces forge-aware for Rithub (Gitea)
Rithub (Gitea) repos were imported into the ritgram DB but most backend
paths and frontend views still assumed GitHub only:

- repositoryService.searchRepositories/getTrending were pure Octokit calls
  (the two endpoints behind /repositories/search and /repositories/trending,
  used by explore/discover/Feed/TrendingRepos) — now merge our own DB (any
  forge) with live GitHub search/trending, with Rithub repos listed first
  since a brand-new Rithub repo has 0 GitHub-scale stars and a pure
  star-sort would always bury it under unrelated GitHub trending noise.
- repositoryController's follow/unfollow/getPosts/getSnippets/getMedia/
  bookmark/update/remove/aitm-settings/etc. all resolved the repo via
  getRepository(owner, name) with no forge param (silently defaulting to
  github) — now thread ?forge= through via a resolveForge(req) helper.
- getActivityTimeline (repo activity feed) had the same default-to-github
  gap — now forge-aware too.
- searchController's repo selects (unifiedSearch/searchAll/searchRepositories/
  getPersonalizedTrending) didn't return `forge`, so the frontend had no way
  to badge or route Gitea rows differently — added `forge`/`htmlUrl` to each.
- trendingAlgorithmService.getTrendingRepositories merged by bare fullName,
  which could wrongly conflate a same-named GitHub and Gitea repo now that
  fullName is only forge-scoped unique — merge key is now `forge:fullName`.
- Added a periodic Gitea repo re-sync (jobs/syncGiteaRepos.ts, every 6h),
  reusing the exact upsert logic from scripts/importGiteaRepos.ts via a new
  shared services/giteaSyncService.ts — one real implementation, idempotent.
- Frontend: RepoCard/RepositorySocialCard/TrendingRepos/search page/trending
  page now show a "Rithub" badge on non-GitHub repos (web/lib/forge.ts).
  Fixed two unrelated pre-existing bugs found while wiring this up: the
  trending page sent invalid tier values (TRENDING_TODAY instead of the
  backend's today/week/hot/rising aliases) and unwrapped the wrong level of
  the {success,data:{...}} response envelope, so every trending panel showed
  "failed to load" / empty regardless of forge.

Verified locally: backend+frontend running against the real ritgram Neon DB,
curled search/trending/repo-detail(?forge=gitea), and a logged-in headless
Chrome screenshot of /search and /trending showing the 14 real Rithub repos
with the "Rithub" badge. tsc --noEmit clean on backend and web.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-13 16:15:11 +03:00
..