Skip to content
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

Back 62 afegir nivells de prioritat de empreses #247

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""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
Expand All @@ -18,6 +18,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 ###


Expand Down
2 changes: 1 addition & 1 deletion src/impl/Company/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down
4 changes: 2 additions & 2 deletions src/impl/Company/router_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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=list[CompanyGet])
def get_by_tier(tier: int):
return company_service.get_by_tier(tier)
13 changes: 1 addition & 12 deletions src/impl/Company/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def tier_validator(cls, v):


class CompanyGet(BaseSchema):
id: int
name: str
description: str
website: str
Expand All @@ -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

Expand Down
4 changes: 1 addition & 3 deletions src/impl/Company/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +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(ModelCompany).filter(
ModelCompany.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]):
Expand Down
Loading