Skip to content

Commit

Permalink
LTI-411: reduce database queries to improve performance (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariam05 authored Nov 14, 2024
1 parent 16a8c4b commit efbaa99
Showing 1 changed file with 8 additions and 4 deletions.
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

0 comments on commit efbaa99

Please sign in to comment.