Skip to content

Commit

Permalink
Backend throwing 500 error due to organization name
Browse files Browse the repository at this point in the history
  • Loading branch information
areyeslo committed Jan 16, 2025
1 parent c402ae7 commit d793d7c
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions backend/lcfs/web/api/final_supply_equipment/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,23 @@ async def get_organization_names(self, organization) -> List[str]:
Returns:
List[str]: A list of unique organization names.
"""
organization_names = (
await self.db.execute(
select(distinct(FinalSupplyEquipment.organization_name))
.join(ComplianceReport, FinalSupplyEquipment.compliance_report_id == ComplianceReport.compliance_report_id)
.filter(ComplianceReport.organization_id == organization.organization_id)
.filter(FinalSupplyEquipment.organization_name.isnot(None))
)
).all()
try:
if not organization or not organization.organization_id:
return []

organization_names = (
await self.db.execute(
select(distinct(FinalSupplyEquipment.organization_name))
.join(ComplianceReport, FinalSupplyEquipment.compliance_report_id == ComplianceReport.compliance_report_id)
.filter(ComplianceReport.organization_id == organization.organization_id)
.filter(FinalSupplyEquipment.organization_name.isnot(None))
)
).all()

# Extract strings from the list of tuples
return [name[0] for name in organization_names]
return [name[0] for name in organization_names]
except Exception as e:
logger.error("Error getting organization names", error=str(e))
return []

@repo_handler
async def get_intended_user_by_name(self, intended_user: str) -> EndUseType:
Expand Down

0 comments on commit d793d7c

Please sign in to comment.