Skip to content

Implement ?group_by_collection query parameter for user projects#465

Open
cycomachead wants to merge 1 commit into
mainfrom
cycomachead/ai/34/1
Open

Implement ?group_by_collection query parameter for user projects#465
cycomachead wants to merge 1 commit into
mainfrom
cycomachead/ai/34/1

Conversation

@cycomachead
Copy link
Copy Markdown
Member

Add ?group_by_collection query parameter for user projects

Implements a new group_by_collection query parameter on GET /projects that returns the current user's projects organized into folder-like groups by collection, enabling downstream "folder" views.

Changes

  • New my_projects_grouped action (controllers/project.lua): When ?group_by_collection is set, returns a structured response:
    {
      "collections": [{ "id": ..., "name": ..., "projects": [...] }, ...],
      "projects": [...]
    }
    • collections includes only collections where the current user is a creator or editor
    • Projects belonging to multiple user collections appear once per collection
    • Top-level projects holds projects not in any of the user's collections, ordered by lastupdated DESC
    • Collections ordered by updated_at DESC; projects within a collection ordered by membership created_at DESC
  • Unchanged behavior: Requests without ?group_by_collection continue to use the existing paginated list response
  • API docs updated (static/API) to document the new parameter and response shape

Reviewer Notes

  • Scoped to GET /api/v1/projects (logged-in user's own projects only). Applying this to /projects/:username has ambiguous semantics and is left for a follow-up if needed.
  • The grouped response is not paginated — folder views typically render the full tree, and a user's own project/collection count is bounded.
  • No automated test suite exists in the repo; manual verification with a logged-in user against a running Postgres instance is recommended before merging.

Superconductor Ticket Implementation | App Preview | Guided Review

Added a new `group_by_collection` parameter to the projects endpoint that
returns a structured response of collections and their associated projects.

- Groups projects into collections where the user is a creator or editor.
- Lists projects multiple times if they belong to multiple user collections.
- Returns projects not in any user collection in a top-level array.
- Preserves existing ordering logic for both collections and projects.
- Updates API documentation to reflect the new response format.

Co-authored-by: Claude Code <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