-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b3e4dc
commit 444289f
Showing
17 changed files
with
154 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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 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,7 @@ | ||
import strawberry | ||
|
||
|
||
@strawberry.type | ||
class MangaBranchMutation: | ||
async def create(self) -> None: | ||
pass |
Empty file.
This file contains 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,22 @@ | ||
from typing import Self | ||
|
||
import strawberry | ||
|
||
from app.adapters.graphql.dto import DTOMixin | ||
from app.adapters.graphql.types import LanguageGQL | ||
from app.db.models import MangaBranch | ||
|
||
|
||
@strawberry.type(name="MangaBranch") | ||
class MangaBranchGQL(DTOMixin[MangaBranch]): | ||
id: strawberry.ID | ||
name: str | ||
language: LanguageGQL | ||
|
||
@classmethod | ||
def from_dto(cls, model: MangaBranch) -> Self: | ||
return cls( | ||
id=strawberry.ID(str(model)), | ||
name=model.name, | ||
language=model.language, | ||
) |
This file contains 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 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 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import strawberry | ||
|
||
from lib.types import Language | ||
from lib.types import Language, MangaStatus | ||
|
||
LanguageGQL = strawberry.enum(Language, name="LanguageEnum") | ||
MangaStatusGQL = strawberry.enum(MangaStatus, name="MangaStatus") |
This file contains 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 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 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 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,32 @@ | ||
from enum import IntEnum | ||
from typing import TypeVar | ||
|
||
from sqlalchemy import Dialect, Integer, TypeDecorator | ||
|
||
TEnum = TypeVar("TEnum", bound=IntEnum) | ||
|
||
|
||
class IntEnumType(TypeDecorator[TEnum]): | ||
impl = Integer | ||
|
||
def __init__(self, enum: type[TEnum]) -> None: | ||
super().__init__() | ||
self.enum = enum | ||
|
||
def process_bind_param( | ||
self, | ||
value: TEnum | None, | ||
dialect: Dialect, # noqa: ARG002 | ||
) -> int | None: | ||
if value is None: | ||
return None | ||
return value.value | ||
|
||
def process_result_value( | ||
self, | ||
value: int | None, | ||
dialect: Dialect, # noqa: ARG002 | ||
) -> TEnum | None: | ||
if value is None: | ||
return value | ||
return self.enum(value) |
31 changes: 31 additions & 0 deletions
31
src/app/db/migrations/versions/2024-02-27-23-51-58_01aa09cf16f4_add_manga_status.py
This file contains 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,31 @@ | ||
""" | ||
Add manga status | ||
Revision ID: 01aa09cf16f4 | ||
Revises: d8d2a40af9fb | ||
Create Date: 2024-02-27 23:51:58.269706 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
from sqlalchemy import Integer | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "01aa09cf16f4" | ||
down_revision: str | None = "d8d2a40af9fb" | ||
branch_labels: str | None = None | ||
depends_on: str | None = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.add_column( | ||
"manga", | ||
sa.Column("status", Integer, nullable=True), | ||
) | ||
op.execute("update manga set status = 0;") | ||
op.alter_column("manga", "status", nullable=False) | ||
|
||
|
||
def downgrade() -> None: | ||
op.drop_column("manga", "status") |
This file contains 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 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 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 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 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