<commit_before>class UsersController < ApplicationController
  before_action :set_user, only: [:show, :edit, :update, :destroy]

  def report_card
    @reports = current_user.report_card
    @watched_users = current_user.profile_watched_users
    @twitter_profile_name = current_user.twitteruser.name
    @twitter_handle = current_user.twitteruser.nickname
    @twitter_profile_image = current_user.twitteruser.larger_image
  end

  def watch
    @user = User.find(params[:id])
    @user.watch(current_user)
    redirect_to show_path(@user)
  end

  # GET /users
  # GET /users.json

  # GET /users/1
  # GET /users/1.json
  def show
    @current_user = current_user
    @watched_users = current_user.profile_watched_users
    @watched_user_endorsements = @watched_users.map { |twitteruser| twitteruser.user.profile_endorsed_candidates }

    @twitter_profile_name = current_user.twitteruser.name
    @twitter_handle = current_user.twitteruser.nickname
    @twitter_profile_image = current_user.twitteruser.larger_image
  end


  # GET /users/new
  def new
    @user = User.new
  end

  # GET /users/1/edit
  def edit
  end

  # POST /users
  # POST /users.json
  def create
   p env["omniauth.auth"]
    User.create_from_omniauth(auth)
    redirect_to root_url

  end

  # PATCH/PUT /users/1
  # PATCH/PUT /users/1.json
  def update
    respond_to do |format|
      if @user.update(user_params)
        format.html { redirect_to @user, notice: 'User was successfully updated.' }
        format.json { render :show, status: :ok, location: @user }
      else
        format.html { render :edit }
        format.json { render json: @user.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /users/1
  # DELETE /users/1.json
  def destroy
    @user.destroy
    respond_to do |format|
      format.html { redirect_to users_url, notice: 'User was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_user
      @user = User.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def user_params
      params.require(:user).permit(:twitter_id, :token, :expires, :district)
    end
end
<commit_msg>fix bug where profile always showed current user's info<commit_after>class UsersController < ApplicationController
  before_action :set_user, only: [:show, :edit, :update, :destroy]

  def report_card
    @reports = current_user.report_card
    @watched_users = current_user.profile_watched_users
    @twitter_profile_name = current_user.twitteruser.name
    @twitter_handle = current_user.twitteruser.nickname
    @twitter_profile_image = current_user.twitteruser.larger_image
  end

  def watch
    @user = User.find(params[:id])
    @user.watch(current_user)
    redirect_to show_path(@user)
  end

  # GET /users
  # GET /users.json

  # GET /users/1
  # GET /users/1.json
  def show
    @current_user = current_user
    @user = User.find(params[:id])
    @watched_users = @user.profile_watched_users
    @watched_user_endorsements = @watched_users.map { |twitteruser| twitteruser.user.profile_endorsed_candidates }

    @twitter_profile_name = @user.twitteruser.name
    @twitter_handle = @user.twitteruser.nickname
    @twitter_profile_image = @user.twitteruser.larger_image
  end


  # GET /users/new
  def new
    @user = User.new
  end

  # GET /users/1/edit
  def edit
  end

  # POST /users
  # POST /users.json
  def create
   p env["omniauth.auth"]
    User.create_from_omniauth(auth)
    redirect_to root_url

  end

  # PATCH/PUT /users/1
  # PATCH/PUT /users/1.json
  def update
    respond_to do |format|
      if @user.update(user_params)
        format.html { redirect_to @user, notice: 'User was successfully updated.' }
        format.json { render :show, status: :ok, location: @user }
      else
        format.html { render :edit }
        format.json { render json: @user.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /users/1
  # DELETE /users/1.json
  def destroy
    @user.destroy
    respond_to do |format|
      format.html { redirect_to users_url, notice: 'User was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_user
      @user = User.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def user_params
      params.require(:user).permit(:twitter_id, :token, :expires, :district)
    end
end

{'fraction_non_alphanumeric': 0.0921193901653425, 'fraction_numerical': 0.003006227184882972, 'mean_word_length': 3.1552185548617304, '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': '955083', 'n_tokens_mistral': 1528, 'n_tokens_neox': 1482, 'n_words': 368}