Set a pending connection to connected when the warehouse has received at least one event. No-op otherwise.
(
connection: WarehouseConnection,
stats: WarehouseEventStats,
)
| 728 | |
| 729 | |
| 730 | def refresh_warehouse_connection_status( |
| 731 | connection: WarehouseConnection, |
| 732 | stats: WarehouseEventStats, |
| 733 | ) -> WarehouseConnection: |
| 734 | """Set a pending connection to connected when the warehouse has received at |
| 735 | least one event. No-op otherwise.""" |
| 736 | if ( |
| 737 | connection.status == WarehouseConnectionStatus.PENDING_CONNECTION |
| 738 | and stats.total_events_received > 0 |
| 739 | ): |
| 740 | connection.status = WarehouseConnectionStatus.CONNECTED |
| 741 | connection.save(update_fields=["status"]) |
| 742 | logger.info( |
| 743 | "connection.connected", |
| 744 | environment__id=connection.environment_id, |
| 745 | organisation__id=connection.environment.project.organisation_id, |
| 746 | ) |
| 747 | return connection |
| 748 | |
| 749 | |
| 750 | def annotate_warehouse_event_stats( |