Skip to content

Conversation

@evanpurkhiser
Copy link
Member

Removes the computed property Monitor.is_muted and replaces it with a standalone
is_monitor_muted(monitor) function for better clarity and to fix an N+1 query
issue in MonitorSerializer.

The serializer now efficiently computes mute status for multiple monitors in a
single pass by checking if any environment is unmuted, rather than calling the
property on each monitor individually which would trigger separate queries.

Changes:

  • Removed @Property is_muted from Monitor model
  • Added standalone is_monitor_muted() function that aggregates environment mute status
  • Updated MonitorSerializer to compute is_muted efficiently using defaultdict pattern
  • Updated all test files to use is_monitor_muted(monitor) instead of monitor.is_muted

@evanpurkhiser evanpurkhiser requested a review from a team as a code owner November 19, 2025 22:20
@evanpurkhiser evanpurkhiser requested review from a team and markstory November 19, 2025 22:20
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 19, 2025
…roperty

Removes the computed property Monitor.is_muted and replaces it with a standalone
is_monitor_muted(monitor) function for better clarity and to fix an N+1 query
issue in MonitorSerializer.

The serializer now efficiently computes mute status for multiple monitors in a
single pass by checking if any environment is unmuted, rather than calling the
property on each monitor individually which would trigger separate queries.

Changes:
- Removed @Property is_muted from Monitor model
- Added standalone is_monitor_muted() function that aggregates environment mute status
- Updated MonitorSerializer to compute is_muted efficiently using defaultdict pattern
- Updated all test files to use is_monitor_muted(monitor) instead of monitor.is_muted
@evanpurkhiser evanpurkhiser force-pushed the evanpurkhiser/ref-crons-fix-n-1-query-in-monitorserializer-by-removing-is-muted-property branch from d5f30bf to 689a7f3 Compare November 19, 2025 23:32
@evanpurkhiser evanpurkhiser merged commit 8e863ac into master Nov 20, 2025
65 checks passed
@evanpurkhiser evanpurkhiser deleted the evanpurkhiser/ref-crons-fix-n-1-query-in-monitorserializer-by-removing-is-muted-property branch November 20, 2025 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants