This change reorders the status determination logic to check for
busy conditions first, ensuring successful transmissions are
correctly marked as 'sent' and trigger the proper success email.
Replaced unindexable CONCAT() with COALESCE(col, '') || ... and refactored dialplan lookup into a CTE with UNION to split destination-based and public-context paths.
CONCAT() is marked as STABLE in PostgreSQL and cannot be used in functional indexes, which forced sequential scans during dialplan lookups. To enable future indexing and improve query optimizability, we replace all CONCAT(a, b, c) calls with (COALESCE(a, '') || COALESCE(b, '') || COALESCE(c, '')), which is functionally equivalent for text columns (treating NULLs as empty) and composed only of IMMUTABLE operations.
Additionally, the query was refactored using a CTE with UNION to decompose a complex top-level OR condition into two independent branches:
1. Dialplans linked to matching destinations.
2. Public dialplans with domain_uuid IS NULL.
This structure allows the planner to optimize each path separately, avoid full-table scans, and leverage primary key lookups efficiently - even without additional indexes.
On a production dataset with 3kk records in v_dialplans, this change reduced dialplans query latency from ~1.5s to ~37ms (40.5x faster), with further gains possible via expression indexes.
* Fix widget name setting not being used on some widget labels
* Update app_languages.php
* Add translations for active calls labels and titles
* Update active_calls.php
* Update call_forward.php
* Update device_keys.php
* Add multi-lingual support for widget labels
Updated widget label to support multi-lingual text.
* Update caller_id.php
* Add multilingual support and update widget label
* Update switch_status.php
* Update system_counts.php
* Replace static title with localized widget label
Updated widget title to use localized label.
* Add multilingual support for disk usage widget
* Add translations for system disk usage labels
* Update system_status.php
* Update system_network_status.php
* Add multi-lingual support for CPU status widget
* Update app_languages.php
* Update app_languages.php
* Update voicemails.php
* Add multi-lingual support for missed calls widget
* Update recent_calls.php
* Simplify widget label assignment using null coalescing
* Update call_center_agents.php
* Update app_languages.php