GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor: tenants module uses integer ids · IDTS-LAB/python-codebase@48dce53

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/modules/tenants
    • domain
      • entities
        • tenant.py
      • repositories
        • tenant_repository.py
    • infrastructure/repositories
      • tenant_repository.py
    • presentation
      • schemas.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/modules/tenants/domain/entities/tenant.py‎

Copy file name to clipboardExpand all lines: src/modules/tenants/domain/entities/tenant.py
+3-6Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
from uuid import UUID
2-
3-
41
class Tenant:
52
def __init__(
63
self,
7-
id: UUID,
8-
name: str,
9-
slug: str,
4+
id: int | None = None,
5+
name: str = "",
6+
slug: str = "",
107
domain: str | None = None,
118
):
129
self.id = id
Collapse file

‎src/modules/tenants/domain/repositories/tenant_repository.py‎

Copy file name to clipboard
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from uuid import UUID
2-
31
from src.modules.tenants.domain.entities.tenant import Tenant
42

53

@@ -8,6 +6,6 @@ async def get_by_slug(self, slug: str) -> Tenant | None: ...
86

97
async def get_by_domain(self, domain: str) -> Tenant | None: ...
108

11-
async def get_by_id(self, tenant_id: UUID) -> Tenant | None: ...
9+
async def get_by_id(self, tenant_id: int) -> Tenant | None: ...
1210

1311
async def save(self, tenant: Tenant) -> Tenant: ...
Collapse file

‎src/modules/tenants/infrastructure/repositories/tenant_repository.py‎

Copy file name to clipboardExpand all lines: src/modules/tenants/infrastructure/repositories/tenant_repository.py
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from uuid import UUID
2-
31
from sqlalchemy import select
42
from sqlalchemy.ext.asyncio import AsyncSession
53

@@ -26,7 +24,7 @@ async def get_by_domain(self, domain: str) -> Tenant | None:
2624
model = result.scalar_one_or_none()
2725
return self._to_entity(model) if model else None
2826

29-
async def get_by_id(self, tenant_id: UUID) -> Tenant | None:
27+
async def get_by_id(self, tenant_id: int) -> Tenant | None:
3028
result = await self._db.execute(
3129
select(TenantModel).where(TenantModel.id == tenant_id)
3230
)
@@ -45,7 +43,6 @@ async def save(self, tenant: Tenant) -> Tenant:
4543
model.domain = tenant.domain
4644
else:
4745
model = TenantModel(
48-
id=tenant.id,
4946
name=tenant.name,
5047
slug=tenant.slug,
5148
domain=tenant.domain,
@@ -56,7 +53,7 @@ async def save(self, tenant: Tenant) -> Tenant:
5653
await self._db.refresh(model)
5754
return self._to_entity(model)
5855

59-
async def _get_model(self, tenant_id: UUID) -> TenantModel:
56+
async def _get_model(self, tenant_id: int) -> TenantModel:
6057
result = await self._db.execute(
6158
select(TenantModel).where(TenantModel.id == tenant_id)
6259
)
Collapse file

‎src/modules/tenants/presentation/schemas.py‎

Copy file name to clipboardExpand all lines: src/modules/tenants/presentation/schemas.py
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
from uuid import UUID
2-
31
from pydantic import BaseModel
42

53

64
class TenantResponse(BaseModel):
7-
id: UUID
5+
id: int
86
name: str
97
slug: str
108
domain: str | None = None

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.