Skip to content

Commit

Permalink
Fix company profile pic url in get and list api
Browse files Browse the repository at this point in the history
  • Loading branch information
shri committed Aug 27, 2024
1 parent 904a127 commit fe3ea7f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/app/domain/companies/controllers/companies.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from litestar.di import Provide

from app.config import constants
from app.lib.utils import get_logo_dev_link
from app.domain.accounts.guards import requires_active_user
from app.domain.companies import urls
from app.domain.companies.dependencies import provide_companies_service
Expand Down Expand Up @@ -48,7 +49,13 @@ async def list_companies(
) -> OffsetPagination[Company]:
"""List companies that your account can access.."""
results, total = await companies_service.list_and_count(*filters)
return companies_service.to_schema(data=results, total=total, schema_type=Company, filters=filters)
paginated_response = companies_service.to_schema(
data=results, total=total, schema_type=Company, filters=filters
)
# Workaround due to https://github.com/jcrist/msgspec/issues/673
for company in paginated_response.items:
company.profile_pic_url = get_logo_dev_link(company.url)
return paginated_response

@post(
operation_id="CreateCompany",
Expand Down Expand Up @@ -85,9 +92,10 @@ async def get_company(
) -> Company:
"""Get details about a comapny."""
db_obj = await companies_service.get(company_id)
# company = companies_service.to_schema(schema_type=Company, data=db_obj)
company = companies_service.to_schema(schema_type=Company, data=db_obj)
# Workaround due to https://github.com/jcrist/msgspec/issues/673
return Company.from_dict(db_obj.to_dict())
company.profile_pic_url = get_logo_dev_link(company.url)
return company

@patch(
operation_id="UpdateCompany",
Expand Down

0 comments on commit fe3ea7f

Please sign in to comment.