<commit_before>class StaffplansController < ApplicationController
  
  def show
    @from = Date.parse(params[:from] || '').at_beginning_of_week rescue Date.today.at_beginning_of_week
    @from = 1.week.ago(@from)
    @target_user = UserDecorator.new(current_user.current_company.users.find_by_id(params[:id]))
    redirect_to root_url, error: I18n.t('controllers.staffplans.couldnt_find_user') and return unless @target_user.model.present?
    
    respond_to do |format|
      format.html do
      end
    
      format.mobile do
        @date = (Date.parse(params[:date]) rescue Date.today).at_beginning_of_week
        @projects = @target_user.projects.group_by { |project| project.client.name }
        render(layout: false) if request.xhr?
      end
    end
  end
 
  def inactive
    @users = UserDecorator.decorate(current_user.current_company.inactive_users.sort { |a,b| a.last_name <=> b.last_name })
  end

  def index
    @start = params[:from] # We need to save that for the view
    @sort ||= params[:sort]
    @from = Date.parse(params[:from] || '').at_beginning_of_week rescue Date.today.at_beginning_of_week
    @from = 1.week.ago(@from)
    @to = 3.months.from_now(@from)
    
    @date_range = []
    start = @from.clone
    
    while start < @to
      @date_range << start
      start = start + 7.days
    end
    project_ids = current_user.current_company.projects.map(&:id)
    
    u = current_user.current_company.active_users.sort do |a, b|
      if @sort.nil? || @sort == "workload"
        a.plan_for(project_ids, @date_range.first) <=> b.plan_for(project_ids, @date_range.first)
      else
        a.last_name <=> b.last_name
      end 
    end
    @users = UserDecorator.decorate(u)
  end
  
  def my_staffplan
    redirect_to staffplan_url(current_user)
  end
end<commit_msg>We don't need any of this.<commit_after>class StaffplansController < ApplicationController
  
  def show
    respond_to do |format|
      format.html {}
      format.mobile do
        @date = (Date.parse(params[:date]) rescue Date.today).at_beginning_of_week
        @projects = @target_user.projects.group_by { |project| project.client.name }
        render(layout: false) if request.xhr?
      end
    end
  end
 
  def inactive
    @users = UserDecorator.decorate(current_user.current_company.inactive_users.sort { |a,b| a.last_name <=> b.last_name })
  end

  def index
  end
  
  def my_staffplan
    redirect_to staffplan_url(current_user)
  end
end
{'fraction_non_alphanumeric': 0.11011783827712313, 'fraction_numerical': 0.002438033319788704, 'mean_word_length': 3.1587837837837838, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 7, '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': '118178', 'n_tokens_mistral': 851, 'n_tokens_neox': 830, 'n_words': 164}