<commit_before>class SettingsController < ApplicationController
  layout "skinny"

  before_filter :authenticate_user!

  def edit
    offset = ActiveSupport::TimeZone[current_user.time_zone].utc_offset / 1.hour
    @prompt_delivery_hour = current_user.prompt_delivery_hour + offset
  end

  def update
    time_zone = params[:user][:time_zone]
    offset = ActiveSupport::TimeZone[time_zone].utc_offset / 1.hour
    prompt_delivery_hour = params[:date][:prompt_delivery_hour].to_i - offset

    current_user.update_attributes(
      time_zone: time_zone,
      prompt_delivery_hour: prompt_delivery_hour
    )

    flash[:notice] = "Your settings have been saved."

    redirect_to dashboard_path
  end
end<commit_msg>Extract user and utc offsets to methods<commit_after>class SettingsController < ApplicationController
  layout "skinny"

  before_filter :authenticate_user!

  def edit
    @prompt_delivery_hour = user_prompt_delivery_hour
  end

  def update
    current_user.update_attributes(
      time_zone: params[:user][:time_zone],
      prompt_delivery_hour: utc_prompt_delivery_hour
    )

    flash[:notice] = "Your settings have been saved."

    redirect_to dashboard_path
  end

  private

  def user_prompt_delivery_hour
    current_user.prompt_delivery_hour + offset(current_user.time_zone)
  end

  def utc_prompt_delivery_hour
    params[:date][:prompt_delivery_hour].to_i -
    offset(params[:user][:time_zone])
  end

  def offset(time_zone)
    ActiveSupport::TimeZone[time_zone].utc_offset / 1.hour
  end
end
{'fraction_non_alphanumeric': 0.07637075718015666, 'fraction_numerical': 0.0019582245430809398, 'mean_word_length': 4.475, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5613611', 'n_tokens_mistral': 512, 'n_tokens_neox': 479, 'n_words': 91}