Integration hooks loading more frequently than necessary
This issue came out of this discussion &7290 (comment 1175265005).
Problem
Nearly all hook event properties are default set to true
for all integrations regardless of whether the integration uses the hooks or not.
Only integrations that specifically allow people to check and uncheck the hook event options in the integration form can have false
values for some events (limited to integrations that inherit from BaseChatNotification
only).
The integration models themselves implement a .supported_events
method that specifies whether they support the events, but that is checked later at the point where we have loaded the record and attempted to execute it.
The unfortunate result of this is that the Project#has_active_integrations?
check is much less helpful in terms of a performance optimisation made before attempting to evaluate data payloads or execute integration hooks, as projects with any enabled integrations will generally report true
even when it's not.
We're likely to be loading integrations very frequently, and building data
payloads, which ultimately are all for nothing.
This will lead to many unnecessary PostgreSQL queries.
Proposal
- Integrations should always set event properties that don't correlate to the model's
.supported_events
tofalse
. - Add a data migration to correct existing data.