[2f388f42] Implementierung der UI-Anpassungen zur Anzeige von ausstehenden Fehlerberichten (rote Flagge in der Unternehmensliste, Anzeige im Inspector) und zur Ermöglichung weiterer Fehlerberichte. Backend-APIs wurden entsprechend erweitert.
Implementierung der UI-Anpassungen zur Anzeige von ausstehenden Fehlerberichten (rote Flagge in der Unternehmensliste, Anzeige im Inspector) und zur Ermöglichung weiterer Fehlerberichte. Backend-APIs wurden entsprechend erweitert.
This commit is contained in:
@@ -107,6 +107,22 @@ def list_companies(
|
||||
query = query.order_by(Company.name.asc())
|
||||
|
||||
items = query.offset(skip).limit(limit).all()
|
||||
|
||||
# Efficiently check for pending mistakes
|
||||
company_ids = [c.id for c in items]
|
||||
if company_ids:
|
||||
pending_mistakes = db.query(ReportedMistake.company_id).filter(
|
||||
ReportedMistake.company_id.in_(company_ids),
|
||||
ReportedMistake.status == 'PENDING'
|
||||
).distinct().all()
|
||||
companies_with_pending_mistakes = {row[0] for row in pending_mistakes}
|
||||
else:
|
||||
companies_with_pending_mistakes = set()
|
||||
|
||||
# Add the flag to each company object
|
||||
for company in items:
|
||||
company.has_pending_mistakes = company.id in companies_with_pending_mistakes
|
||||
|
||||
return {"total": total, "items": items}
|
||||
except Exception as e:
|
||||
logger.error(f"List Companies Error: {e}", exc_info=True)
|
||||
@@ -251,6 +267,7 @@ def list_job_roles(db: Session = Depends(get_db)):
|
||||
@app.get("/api/mistakes")
|
||||
def list_reported_mistakes(
|
||||
status: Optional[str] = Query(None),
|
||||
company_id: Optional[int] = Query(None),
|
||||
skip: int = 0,
|
||||
limit: int = 50,
|
||||
db: Session = Depends(get_db)
|
||||
@@ -260,6 +277,9 @@ def list_reported_mistakes(
|
||||
if status:
|
||||
query = query.filter(ReportedMistake.status == status.upper())
|
||||
|
||||
if company_id:
|
||||
query = query.filter(ReportedMistake.company_id == company_id)
|
||||
|
||||
total = query.count()
|
||||
items = query.order_by(ReportedMistake.created_at.desc()).offset(skip).limit(limit).all()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user