Get WiFi network analytics for one or all networks. Args: ssid: Specific SSID or None for all networks Returns: List of analytics dicts sorted by priority score
(self, ssid: str = None)
| 1755 | now if success else None, |
| 1756 | failure_reason if not success else None, |
| 1757 | success_rate, |
| 1758 | priority_score, |
| 1759 | now |
| 1760 | )) |
| 1761 | |
| 1762 | conn.commit() |
| 1763 | |
| 1764 | except Exception as e: |
| 1765 | logger.error(f"Error updating WiFi analytics: {e}") |
| 1766 | |
| 1767 | def get_wifi_network_analytics(self, ssid: str = None) -> List[Dict[str, Any]]: |
| 1768 | """ |
| 1769 | Get WiFi network analytics for one or all networks. |
| 1770 | |
| 1771 | Args: |
| 1772 | ssid: Specific SSID or None for all networks |
| 1773 | |
| 1774 | Returns: |
| 1775 | List of analytics dicts sorted by priority score |
| 1776 | """ |
| 1777 | try: |
| 1778 | with self.get_connection() as conn: |
| 1779 | cursor = conn.cursor() |
| 1780 | |
| 1781 | if ssid: |
| 1782 | cursor.execute(""" |
| 1783 | SELECT * FROM wifi_network_analytics |
| 1784 | WHERE ssid = ? |
| 1785 | """, (ssid,)) |
| 1786 | else: |
| 1787 | cursor.execute(""" |
| 1788 | SELECT * FROM wifi_network_analytics |
| 1789 | ORDER BY priority_score DESC |
| 1790 | """) |
| 1791 | |
| 1792 | columns = [desc[0] for desc in cursor.description] |
| 1793 | results = [] |
| 1794 | |
| 1795 | for row in cursor.fetchall(): |
| 1796 | result = dict(zip(columns, row)) |
| 1797 | results.append(result) |