<commit_before>class WorksController < ApplicationController
  before_filter :load_work, only: [:show, :edit, :update, :destroy]
  before_filter :new_work, only: [:create]
  load_and_authorize_resource
  skip_authorize_resource :only => [:show, :index]

  def index
    @page = (params[:page] || 1).to_i
    @q = params[:q]
    @class_name = params[:class_name]
    @publisher = Publisher.where(name: params[:publisher_id]).first
    @source = Source.active.where(name: params[:source_id]).first
    @sort = Source.active.where(name: params[:sort]).first
    @relation_type = cached_relation_type(params[:relation_type_id])
  end

  def show
    format_options = params.slice :events, :source

    @groups = Group.order("id")
    @page = params[:page] || 1
    @source = Source.active.where(name: params[:source_id]).first
    @relation_type = cached_relation_type(params[:relation_type_id])
    render :show
  end

  def new
    @work = Work.new(day: Time.zone.now.day, month: Time.zone.now.month, year: Time.zone.now.year, tracked: true)
    render :index
  end

  def create
    @work.save
    render :index
  end

  def edit
    render :show
  end

  # PUT /works/:id(.:format)
  def update<commit_msg>cache queries for source and publisher<commit_after>class WorksController < ApplicationController
  before_filter :load_work, only: [:show, :edit, :update, :destroy]
  before_filter :new_work, only: [:create]
  load_and_authorize_resource
  skip_authorize_resource :only => [:show, :index]

  def index
    @page = (params[:page] || 1).to_i
    @q = params[:q]
    @class_name = params[:class_name]
    @publisher = cached_publisher(params[:publisher_id])
    @source = cached_source(params[:source_id])
    @sort = Source.active.where(name: params[:sort]).first
    @relation_type = cached_relation_type(params[:relation_type_id])
  end

  def show
    format_options = params.slice :events, :source

    @groups = Group.order("id")
    @page = params[:page] || 1
    @source = cached_source(params[:source_id])
    @relation_type = cached_relation_type(params[:relation_type_id])
    @contributor_role = cached_contributor_role(params[:contributor_role_id])
    render :show
  end

  def new
    @work = Work.new(day: Time.zone.now.day, month: Time.zone.now.month, year: Time.zone.now.year, tracked: true)
    render :index
  end

  def create
    @work.save
    render :index
  end

  def edit
    render :show
  end

  # PUT /works/:id(.:format)
  def update
{'fraction_non_alphanumeric': 0.12884927066450566, 'fraction_numerical': 0.0016207455429497568, 'mean_word_length': 4.038775510204082, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5431427', 'n_tokens_mistral': 838, 'n_tokens_neox': 816, 'n_words': 179}