Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LTI-411: reduce database queries to improve performance #365

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions app/controllers/rooms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,15 @@ def set_room
def set_chosen_room
# See whether shared rooms have been enabled in tenant settings. They are disabled by default.
@shared_rooms_enabled = tenant_setting(@room&.tenant, 'enable_shared_rooms') == 'true'
@shared_room = Room.find_by(code: @room.shared_code, tenant: @room.tenant) if @shared_rooms_enabled && @room&.use_shared_code

use_shared_room = @shared_rooms_enabled && @room&.use_shared_code && Room.where(code: @room.shared_code, tenant: @room.tenant).exists?

logger.debug("Room with id #{params[:id]} is using shared code: #{@room&.shared_code}") if @shared_rooms_enabled && @room&.use_shared_code
if @shared_rooms_enabled && @room&.use_shared_code
@shared_room = Room.find_by(code: @room.shared_code, tenant: @room.tenant)
use_shared_room = @shared_room.present?
logger.debug("Room with id #{params[:id]} is using shared code: #{@room&.shared_code}")
else
@shared_room = nil
use_shared_room = false
end

@chosen_room = use_shared_room ? @shared_room : @room
end
Expand Down