<commit_before>##
# Controller to query the state of SubscribeUserWorker instances enqued for the user.

class Api::SubscribeJobStatesController < ApplicationController

  before_filter :authenticate_user!

  respond_to :json

  ##
  # Return JSON indicating the state of the subscribe jobs initiated by the current user

  def index
    if SubscribeJobState.exists? user_id: current_user.id
      @job_states = SubscribeJobState.where user_id: current_user.id
      Rails.logger.debug "User #{current_user.id} - #{current_user.email} has #{@job_states.count} SubscribeJobState instances"
      render 'index', locals: {job_states: @job_states}
    else
      head status: 404
    end
  rescue => e
    handle_error e
  end

  ##
  # Return JSON indicating the state of a single subscribe job initiated by the current user

  def show
    @job_state = current_user.find_subscribe_job_state params[:id]
    render 'show', locals: {job_state: @job_state}
  rescue => e
    handle_error e
  end

  ##
  # Remove job state from the database. This will make its alert disappear from the start page as well.

  def destroy
    @job_state = current_user.find_subscribe_job_state params[:id]
    Rails.logger.debug "Destroying subscribe_job_state #{@job_state.id} for user #{current_user.id} - #{current_user.email}"
    @job_state.destroy!
    head status: 200
  rescue => e
    handle_error e
  end

end<commit_msg>Added HTTP caching support to SubscribeJobStatesController#show action<commit_after>##
# Controller to query the state of SubscribeUserWorker instances enqued for the user.

class Api::SubscribeJobStatesController < ApplicationController

  before_filter :authenticate_user!

  respond_to :json

  ##
  # Return JSON indicating the state of the subscribe jobs initiated by the current user

  def index
    if SubscribeJobState.exists? user_id: current_user.id
      @job_states = SubscribeJobState.where user_id: current_user.id
      Rails.logger.debug "User #{current_user.id} - #{current_user.email} has #{@job_states.count} SubscribeJobState instances"
      render 'index', locals: {job_states: @job_states}
    else
      head status: 404
    end
  rescue => e
    handle_error e
  end

  ##
  # Return JSON indicating the state of a single subscribe job initiated by the current user

  def show
    @job_state = current_user.find_subscribe_job_state params[:id]
    # If job state has not changed, return a 304
    if stale? last_modified: @job_state.updated_at
      render 'show', locals: {job_state: @job_state}
    end
  rescue => e
    handle_error e
  end

  ##
  # Remove job state from the database. This will make its alert disappear from the start page as well.

  def destroy
    @job_state = current_user.find_subscribe_job_state params[:id]
    Rails.logger.debug "Destroying subscribe_job_state #{@job_state.id} for user #{current_user.id} - #{current_user.email}"
    @job_state.destroy!
    head status: 200
  rescue => e
    handle_error e
  end

end
{'fraction_non_alphanumeric': 0.0747068676716918, 'fraction_numerical': 0.005025125628140704, 'mean_word_length': 3.8239095315024234, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '2398914', 'n_tokens_mistral': 915, 'n_tokens_neox': 877, 'n_words': 295}