Optimize db queries on talk update

This commit is contained in:
Petko Bordjukov 2017-09-28 15:55:18 +03:00
parent 579fd2c04f
commit 436f097038
1 changed files with 2 additions and 2 deletions

View File

@ -26,8 +26,8 @@ class TalkPreferencesController < ApplicationController
def update def update
@talk_preference = TalkPreference.find params[:id] @talk_preference = TalkPreference.find params[:id]
@talk_preference.transaction do @talk_preference.with_lock do
@talk_preference.selected_talks.destroy_all SelectedTalk.where(talk_preference_id: @talk_preference.id).delete_all
if params[:talk_preference].blank? || @talk_preference.update(talk_preference_params) if params[:talk_preference].blank? || @talk_preference.update(talk_preference_params)
render json: { render json: {