From 1d44bcba29fb8638b64cb93e873140a8c116bdb4 Mon Sep 17 00:00:00 2001 From: elver5041 Date: Mon, 23 Sep 2024 23:21:11 +0200 Subject: [PATCH 1/5] fix? --- src/impl/Company/service.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/impl/Company/service.py b/src/impl/Company/service.py index dfd77d0e..1255db9a 100644 --- a/src/impl/Company/service.py +++ b/src/impl/Company/service.py @@ -30,8 +30,8 @@ def get_company(self, companyId: int): return self.get_by_id(companyId) def get_by_tier(self, tier: int): - companies = db.session.query(ModelCompany).filter( - ModelCompany.tier == tier) + companies = db.session.query(Company).filter( + Company.tier == tier) return companies def add_company(self, payload: CompanyCreate, data: BaseToken): From ca11a0ba2dc39132ef0045863d31e359378c6cb6 Mon Sep 17 00:00:00 2001 From: elver5041 Date: Mon, 23 Sep 2024 23:57:51 +0200 Subject: [PATCH 2/5] fix 2 --- ..._20bff18796a3.py => 2024-09-23_23-42__eb5796b93841.py} | 8 +++++--- src/impl/Company/model.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) rename alembic/versions/{2024-09-23_22-37__20bff18796a3.py => 2024-09-23_23-42__eb5796b93841.py} (77%) diff --git a/alembic/versions/2024-09-23_22-37__20bff18796a3.py b/alembic/versions/2024-09-23_23-42__eb5796b93841.py similarity index 77% rename from alembic/versions/2024-09-23_22-37__20bff18796a3.py rename to alembic/versions/2024-09-23_23-42__eb5796b93841.py index fb99284a..79e9ec40 100644 --- a/alembic/versions/2024-09-23_22-37__20bff18796a3.py +++ b/alembic/versions/2024-09-23_23-42__eb5796b93841.py @@ -1,15 +1,16 @@ """empty message -Revision ID: 20bff18796a3 +Revision ID: eb5796b93841 Revises: 83b72cd40dab -Create Date: 2024-09-23 22:37:39.866908 +Create Date: 2024-09-23 23:42:10.913359 """ from alembic import op import sqlalchemy as sa + # revision identifiers, used by Alembic. -revision = '20bff18796a3' +revision = 'eb5796b93841' down_revision = '83b72cd40dab' branch_labels = None depends_on = None @@ -18,6 +19,7 @@ def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('company', sa.Column('tier', sa.Integer(), nullable=True)) + op.execute("UPDATE company SET tier=0") # ### end Alembic commands ### diff --git a/src/impl/Company/model.py b/src/impl/Company/model.py index 73b81eca..dfe2c543 100644 --- a/src/impl/Company/model.py +++ b/src/impl/Company/model.py @@ -14,7 +14,7 @@ class Company(BaseModel): telephone: str = Column(String) website: str = Column(String) image: str = Column(String) - tier: int = Column(Integer) + tier: int = Column(Integer, default=0, nullable=False) # is_image_url: bool = Column(Boolean, default=False) linkdin: str = Column(String) leader_id: int = Column(Integer, ForeignKey('my_user.id')) From aa6af83e04f5324afbc4ded59ef6f151da5c6f76 Mon Sep 17 00:00:00 2001 From: github-actions Date: Mon, 23 Sep 2024 21:59:56 +0000 Subject: [PATCH 3/5] Automated autoyapf fixes --- alembic/versions/2024-09-23_23-42__eb5796b93841.py | 1 - src/impl/Company/service.py | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/alembic/versions/2024-09-23_23-42__eb5796b93841.py b/alembic/versions/2024-09-23_23-42__eb5796b93841.py index 79e9ec40..62b6254d 100644 --- a/alembic/versions/2024-09-23_23-42__eb5796b93841.py +++ b/alembic/versions/2024-09-23_23-42__eb5796b93841.py @@ -8,7 +8,6 @@ from alembic import op import sqlalchemy as sa - # revision identifiers, used by Alembic. revision = 'eb5796b93841' down_revision = '83b72cd40dab' diff --git a/src/impl/Company/service.py b/src/impl/Company/service.py index 1255db9a..c55811d1 100644 --- a/src/impl/Company/service.py +++ b/src/impl/Company/service.py @@ -30,8 +30,7 @@ def get_company(self, companyId: int): return self.get_by_id(companyId) def get_by_tier(self, tier: int): - companies = db.session.query(Company).filter( - Company.tier == tier) + companies = db.session.query(Company).filter(Company.tier == tier) return companies def add_company(self, payload: CompanyCreate, data: BaseToken): From 0f4ecef977ab8402873a404463a81bd7f00e70cc Mon Sep 17 00:00:00 2001 From: elver5041 Date: Tue, 24 Sep 2024 00:05:54 +0200 Subject: [PATCH 4/5] fix router tier --- src/impl/Company/router_v1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/impl/Company/router_v1.py b/src/impl/Company/router_v1.py index 24b24e93..3ba422b9 100644 --- a/src/impl/Company/router_v1.py +++ b/src/impl/Company/router_v1.py @@ -80,6 +80,6 @@ def get_events(companyId: int, token: BaseToken = Depends(JWTBearer())): return company_service.get_company_events(companyId) -@router.get("/{tier}", response_model=CompanyGetByTier) +@router.get("/tier/{tier}", response_model=CompanyGetByTier) def get_by_tier(tier: int): return company_service.get_by_tier(tier) From 9ead94104920eda52a9df8d03db6f60553479fef Mon Sep 17 00:00:00 2001 From: elver5041 Date: Tue, 24 Sep 2024 11:27:39 +0200 Subject: [PATCH 5/5] fix fr --- src/impl/Company/router_v1.py | 4 ++-- src/impl/Company/schema.py | 13 +------------ src/impl/Company/service.py | 3 +-- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/impl/Company/router_v1.py b/src/impl/Company/router_v1.py index 3ba422b9..7086a7b1 100644 --- a/src/impl/Company/router_v1.py +++ b/src/impl/Company/router_v1.py @@ -2,7 +2,7 @@ from fastapi import APIRouter, Depends -from src.impl.Company.schema import CompanyCreate, CompanyGetByTier +from src.impl.Company.schema import CompanyCreate from src.impl.Company.schema import CompanyGet from src.impl.Company.schema import CompanyGetAll from src.impl.Company.schema import CompanyUpdate @@ -80,6 +80,6 @@ def get_events(companyId: int, token: BaseToken = Depends(JWTBearer())): return company_service.get_company_events(companyId) -@router.get("/tier/{tier}", response_model=CompanyGetByTier) +@router.get("/tier/{tier}/", response_model=list[CompanyGet]) def get_by_tier(tier: int): return company_service.get_by_tier(tier) diff --git a/src/impl/Company/schema.py b/src/impl/Company/schema.py index 32eb23e3..1b2a2ef5 100644 --- a/src/impl/Company/schema.py +++ b/src/impl/Company/schema.py @@ -24,6 +24,7 @@ def tier_validator(cls, v): class CompanyGet(BaseSchema): + id: int name: str description: str website: str @@ -35,18 +36,6 @@ class CompanyGet(BaseSchema): telephone: str -class CompanyGetByTier(BaseSchema): - name: str - description: str - website: str - tier: int - image: Optional[str] = None - #is_image_url: Optional[bool] = None - address: str - linkdin: str - telephone: str - - class CompanyGetAll(CompanyGet): id: int diff --git a/src/impl/Company/service.py b/src/impl/Company/service.py index c55811d1..26967c9f 100644 --- a/src/impl/Company/service.py +++ b/src/impl/Company/service.py @@ -30,8 +30,7 @@ def get_company(self, companyId: int): return self.get_by_id(companyId) def get_by_tier(self, tier: int): - companies = db.session.query(Company).filter(Company.tier == tier) - return companies + return db.session.query(Company).filter(Company.tier == tier).all() def add_company(self, payload: CompanyCreate, data: BaseToken): if not data.check([UserType.LLEIDAHACKER]):