Skip to content

Link team repos to problem statements on team approval; TTL-cache the GitHub issues proxy - #260

Open
gregv wants to merge 1 commit into
developfrom
feature/link-team-repos-to-problem-statements
Open

Link team repos to problem statements on team approval; TTL-cache the GitHub issues proxy#260
gregv wants to merge 1 commit into
developfrom
feature/link-team-repos-to-problem-statements

Conversation

@gregv

@gregv gregv commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Why

Companion to frontend PR opportunity-hack/frontend-ohack.dev#336. Project pages couldn't show any code for hackathon-built projects because approve_team wrote the created repo only to the team doc — the problem statement's github field stayed empty forever.

What changed

  • approve_team fix-forward (_link_repo_to_problem_statements in api/teams/teams_service.py): after writing the team's github_links, the new repo is also appended to the github array of the linked problem statement(s). Team problem_statements refs are preferred (handles both string ids and DocumentReferences); the nonprofit fallback applies only when it has exactly one problem statement (ambiguous → skip + log). Dedupes by normalized link, upgrades legacy string-shaped github values to [{name, link}], clears get_single_problem_statement_old's cache, and is fully best-effort — it can never fail the approval flow.
  • 10-min TTL cache on GET /api/github/issues (api/github/github_service.py), keyed per (org, repo, state). The public project pages now fetch this per repo for live issue counts, so the cache protects the shared GITHUB_TOKEN budget. Error responses are not cached.

Ops note

GITHUB_TOKEN currently returns 401 Bad credentials in prod (verified via curl https://api.ohack.dev/api/github/issues?...) — the issues proxy and the admin team-management issue summaries are silently broken until the token is rotated.

🤖 Generated with Claude Code

…roxy

Fix-forward for the project-page discoverability gap: approve_team created
the GitHub repo and wrote github_links on the team doc only, so problem
statements' github field stayed empty and /project/<id> showed no code.

- approve_team now also appends {name, link} to the github array of the
  team's linked problem statement(s) via _link_repo_to_problem_statements:
  team.problem_statements refs preferred (string ids and DocumentReferences
  both handled); falls back to the nonprofit's problem statement only when
  it has exactly one (ambiguous cases skip + log). Dedupes by normalized
  link, converts legacy string-shaped github values, clears the cached
  get_single_problem_statement_old read, and never blocks the approval flow.
- GET /api/github/issues responses are now cached 10 min per
  (org, repo, state) — the public project pages fetch this per repo, so the
  cache protects the shared GITHUB_TOKEN rate budget. Errors are not cached
  so transient GitHub failures retry.

Note: GITHUB_TOKEN currently returns 401 Bad credentials in prod — the
issues proxy (and admin issue summaries) won't work until it's rotated.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant