Rename RepositoryNode issues/releases to recent_issues / recent_releases
- Dominant language
- Python
- Stars
- 451
- Forks
- 707
- Avg merge
- 22h 59m
- Merged PRs (30d)
- 91
Description
**Describe the issue**
The GraphQL `RepositoryNode` in `backend/apps/github/api/internal/nodes/repository.py` exposes two fields named `issues` and `releases` that actually return **recent** items (limited, ordered). In-code TODOs ask to rename them to `recent_issues` and `recent_releases` for clarity and consistency with `ProjectNode`, which already uses those names.
- **File:** `backend/apps/github/api/internal/nodes/repository.py`
- **Lines:** 45–47 (`issues`), 81–85 (`releases`)
**Current behavior**
- Schema fields are `issues` and `releases`; both return a slice of recent data. Names suggest full sets.
**Expected behavior**
- Schema fields are `recent_issues` and `recent_releases`; same data and limits, clearer names.
**Are you going to work on this?**
- [x] Yes
- [ ] No
**Proposed solution (minimal, will work)**
**Context:** This is a breaking GraphQL rename. Update backend first, then frontend and tests in one PR so the schema and clients stay in sync.
1. **Backend — rename methods and remove TODOs**
In `backend/apps/github/api/internal/nodes/repository.py`:
- Replace the `issues` method (lines 44–48) with the same logic but name `recent_issues`:
```python
@strawberry.field
def recent_issues(self) -> list[IssueNode]:
"""Resolve recent issues."""
return self.issues.select_related("author").order_by("-created_at")[:RECENT_ISSUES_LIMIT]
```
- Replace the `releases` method (lines 81–85) with the same logic but name `recent_releases`:
```python
@strawberry.field
def recent_releases(self) -> list[ReleaseNode]:
"""Resolve recent releases."""
return self.published_releases.order_by("-published_at")[:RECENT_RELEASES_LIMIT]
```
Remove both TODO comments. No other backend code references these field names (only the node and its tests).
2. **Frontend — query and usage**
- In `frontend/src/server/queries/repositoryQueries.ts`, inside the `repository { ... }` selection in `GET_REPOSITORY_DATA`, change `issues` to `recentIssues` and `releases` to `recentReleases` (GraphQL response uses camelCase).
- In `frontend/src/app/organizations/[organizationKey]/repositories/[repositoryKey]/page.tsx`, change `repository.issues` to `repository.recentIssues` and `repository.releases` to `repository.recentReleases` (or the exact property names from your generated types).
- Regenerate GraphQL types (e.g. run the project’s codegen script) so `repositoryQueries.generated.ts` and types reflect `recentIssues` and `recentReleases`.
3. **Backend tests**
In `backend/tests/apps/github/api/internal/nodes/repository_test.py`:
- In `_get_field_by_name` usages: change `"issues"` to `"recent_issues"` and `"releases"` to `"recent_releases"`.
- Rename or update tests that assert on the field (e.g. `test_resolve_issues` → `test_resolve_recent_issues`, `test_resolve_releases` → `test_resolve_recent_releases`).
- In method tests, change `RepositoryNode.issues(mock_repository)` to `RepositoryNode.recent_issues(mock_repository)` and `RepositoryNode.releases(mock_repository)` to `RepositoryNode.recent_releases(mock_repository)`.
Run `make check-test`.
4. **Frontend tests and mocks**
- In `frontend/__tests__/unit/data/mockRepositoryData.ts` (or wherever repository mocks live), rename `issues` to `recentIssues` and `releases` to `recentReleases` to match the new schema.
- In `frontend/__tests__/unit/pages/RepositoryDetails.test.tsx`, update any reference to `repository.issues` (e.g. line 136) to `repository.recentIssues`. Update snapshot or assertions if they depend on field names.
- Run the frontend test suite.
**Additional context**
- **Acceptance criteria:** RepositoryNode exposes only `recent_issues` and `recent_releases`; both TODOs removed; frontend query and pages use new names; backend and frontend tests updated; `make check-test` and frontend tests pass.
- **Labels:** `enhancement`, `backend`, `frontend`
Contributor guide
Assessment
This issue has not been assessed yet.