Generate a performance report for the specified server. Uses the multi-stage pipeline to analyze server performance.
(sid)
| 1584 | ) |
| 1585 | @pga_login_required |
| 1586 | def generate_performance_report(sid): |
| 1587 | """ |
| 1588 | Generate a performance report for the specified server. |
| 1589 | Uses the multi-stage pipeline to analyze server performance. |
| 1590 | """ |
| 1591 | from pgadmin.llm.utils import is_llm_enabled |
| 1592 | from pgadmin.llm.reports.generator import generate_report_sync |
| 1593 | from pgadmin.utils.driver import get_driver |
| 1594 | |
| 1595 | # Check if LLM is configured |
| 1596 | if not is_llm_enabled(): |
| 1597 | return make_json_response( |
| 1598 | success=0, |
| 1599 | errormsg=gettext( |
| 1600 | 'LLM is not configured. Please configure an LLM provider ' |
| 1601 | 'in Preferences > AI.' |
| 1602 | ) |
| 1603 | ) |
| 1604 | |
| 1605 | # Get database connection |
| 1606 | try: |
| 1607 | driver = get_driver(config.PG_DEFAULT_DRIVER) |
| 1608 | manager = driver.connection_manager(sid) |
| 1609 | conn = manager.connection() |
| 1610 | |
| 1611 | if not conn.connected(): |
| 1612 | return make_json_response( |
| 1613 | success=0, |
| 1614 | errormsg=gettext('Server is not connected.') |
| 1615 | ) |
| 1616 | |
| 1617 | # Generate report using pipeline |
| 1618 | context = {} |
| 1619 | success, result = generate_report_sync( |
| 1620 | report_type='performance', |
| 1621 | scope='server', |
| 1622 | conn=conn, |
| 1623 | manager=manager, |
| 1624 | context=context |
| 1625 | ) |
| 1626 | |
| 1627 | if success: |
| 1628 | return make_json_response( |
| 1629 | success=1, |
| 1630 | data={'report': result} |
| 1631 | ) |
| 1632 | else: |
| 1633 | return make_json_response( |
| 1634 | success=0, |
| 1635 | errormsg=result |
| 1636 | ) |
| 1637 | |
| 1638 | except Exception as e: |
| 1639 | return make_json_response( |
| 1640 | success=0, |
| 1641 | errormsg=gettext('Failed to generate report: ') + str(e) |
| 1642 | ) |
| 1643 |
nothing calls this directly
no test coverage detected