Skip to content

Add stack count/limit to self user responses and document the fields#48

Merged
yulmwu merged 6 commits intomainfrom
chore/stack-info
Mar 12, 2026
Merged

Add stack count/limit to self user responses and document the fields#48
yulmwu merged 6 commits intomainfrom
chore/stack-info

Conversation

@yulmwu
Copy link
Member

@yulmwu yulmwu commented Mar 12, 2026

  • Include stack_count and stack_limit in self/me user responses (/api/auth/login, /api/me ...).

Login

POST /api/auth/login

Request

{
    "email": "user@example.com",
    "password": "strong-password"
}

Response 200

{
    "access_token": "<jwt>",
    "refresh_token": "<jwt>",
    "user": {
        "id": 1,
        "email": "user@example.com",
        "username": "user1",
        "role": "user",
        "team_id": 3,
        "team_name": "team-alpha",
        "division_id": 2,
        "division_name": "고등부",
        "stack_count": 0,
        "stack_limit": 3,
        "blocked_reason": null,
        "blocked_at": null
    }
}

Me

GET /api/me

Headers

Authorization: Bearer <access_token>

Response 200

{
    "id": 1,
    "email": "user@example.com",
    "username": "user1",
    "role": "user",
    "team_id": 1,
    "team_name": "서울고등학교",
    "division_id": 2,
    "division_name": "고등부",
    "stack_count": 0,
    "stack_limit": 3,
    "blocked_reason": null,
    "blocked_at": null
}

Errors:

  • 401 invalid token or missing authorization or invalid authorization

Update Me

PUT /api/me

Headers

Authorization: Bearer <access_token>

Request

{
    "username": "new_username"
}

Response 200

{
    "id": 1,
    "email": "user@example.com",
    "username": "new_username",
    "role": "user",
    "team_id": 1,
    "team_name": "서울고등학교",
    "division_id": 2,
    "division_name": "고등부",
    "stack_count": 0,
    "stack_limit": 3,
    "blocked_reason": null,
    "blocked_at": null
}

Errors:

  • 400 invalid input
  • 401 invalid token or missing authorization or invalid authorization
  • 403 user blocked

@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

❌ Patch coverage is 82.92683% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/http/handlers/handler.go 78.57% 2 Missing and 1 partial ⚠️
internal/repo/stack_repo.go 80.00% 1 Missing and 1 partial ⚠️
internal/service/stack_service.go 88.23% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds stack usage metadata (stack_count, stack_limit) to “self” user API responses (login/me/update-me) and documents the new response fields.

Changes:

  • Add StackService.UserStackSummary and wire it into /api/auth/login, /api/me, and PUT /api/me responses.
  • Extend handler response types/tests to include and assert stack_count / stack_limit.
  • Update auth/user docs examples to include the new fields.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/service/stack_service.go Adds UserStackSummary used to populate stack count/limit in self responses.
internal/service/stack_service_test.go Adds unit test coverage for UserStackSummary.
internal/http/handlers/handler.go Computes stack summary during login/me/update-me and includes it in JSON responses.
internal/http/handlers/types.go Extends userMeResponse and updates newUserMeResponse signature to carry stack fields.
internal/http/handlers/handler_test.go Asserts stack_count/stack_limit in login/me/update-me handler tests.
internal/http/handlers/testenv_test.go Enables stack config in handler test environment.
internal/http/integration/testenv_test.go Enables stack config and asserts stack fields in integration login helper.
docs/docs/users.md Documents stack fields in /api/me and related user docs responses.
docs/docs/auth.md Documents stack fields in /api/auth/login response.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@yulmwu yulmwu requested a review from Copilot March 12, 2026 01:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@yulmwu yulmwu merged commit 7e4eb70 into main Mar 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants