-
Notifications
You must be signed in to change notification settings - Fork 325
Add reviewer_status enum and fields #5704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
services/reviewhelper-api/alembic/versions/30a5eeb5f400_add_reviewer_status_column.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| """Add reviewer_status column. | ||
|
|
||
| Revision ID: 30a5eeb5f400 | ||
| Revises: 53f024d8e601 | ||
| Create Date: 2026-02-19 16:26:32.258055 | ||
|
|
||
| """ | ||
|
|
||
| from typing import Sequence, Union | ||
|
|
||
| import sqlalchemy as sa | ||
| from alembic import op | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision: str = "30a5eeb5f400" | ||
| down_revision: Union[str, Sequence[str], None] = "53f024d8e601" | ||
| branch_labels: Union[str, Sequence[str], None] = None | ||
| depends_on: Union[str, Sequence[str], None] = None | ||
|
|
||
| reviewer_status_enum = sa.Enum( | ||
| "BLOCKING", | ||
| "ADDED", | ||
| "ACCEPTED", | ||
| "REJECTED", | ||
| "COMMENTED", | ||
| "ACCEPTED_OLDER", | ||
| "REJECTED_OLDER", | ||
| "RESIGNED", | ||
| name="reviewer_status_enum", | ||
| ) | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| """Upgrade schema.""" | ||
| reviewer_status_enum.create(op.get_bind(), checkfirst=True) | ||
| op.add_column( | ||
| "review_requests", | ||
| sa.Column("reviewer_status", reviewer_status_enum, nullable=True), | ||
| ) | ||
| op.add_column( | ||
| "feedback", | ||
| sa.Column("reviewer_status", reviewer_status_enum, nullable=True), | ||
| ) | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| """Downgrade schema.""" | ||
| op.drop_column("feedback", "reviewer_status") | ||
| op.drop_column("review_requests", "reviewer_status") | ||
| reviewer_status_enum.drop(op.get_bind(), checkfirst=True) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| from pydantic import BaseModel, model_validator | ||
|
|
||
| from app.enums import ActingCapacity, ReviewerStatus | ||
|
|
||
|
|
||
| class UserActionBase(BaseModel): | ||
| """Base model for schemas that include user + acting_capacity fields.""" | ||
|
|
||
| user_id: int | ||
| user_name: str | ||
| acting_capacity: ActingCapacity | None = None | ||
| reviewer_status: ReviewerStatus | None = None | ||
|
|
||
| @model_validator(mode="before") | ||
| @classmethod | ||
| def split_compound_acting_capacity(cls, data): | ||
| if isinstance(data, dict): | ||
| raw = data.get("acting_capacity") | ||
| if isinstance(raw, str) and ":" in raw: | ||
| base, sub = raw.split(":", 1) | ||
| data["acting_capacity"] = base | ||
| data["reviewer_status"] = sub | ||
| return data | ||
|
|
||
| @model_validator(mode="after") | ||
| def validate_reviewer_status(self): | ||
| if ( | ||
| self.reviewer_status is not None | ||
| and self.acting_capacity != ActingCapacity.REVIEWER | ||
| ): | ||
| raise ValueError( | ||
| "reviewer_status can only be set when acting_capacity is 'reviewer'" | ||
| ) | ||
| return self |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.