<commit_before>class BucketsController < ApplicationController
  before_filter :authorize_read_team!
  before_filter :authorize_write_team!, :only => [:create, :update, :destroy, :archive_closed_issues]
  before_action :set_bucket, :only => [:edit, :update, :destroy]

  def index
    if @team.buckets.any?
      team_members
      @buckets = @team.buckets
      @columns = 12 / (@buckets.length > 0 ? @buckets.length : 1)
    elsif @team.present?
      if team_member?
        redirect_to new_team_bucket_path(@team)
      else
        redirect_to teams_path
      end
    else
      redirect_to teams_path
    end
  end

  def new
    @bucket = Bucket.new
  end

  def edit
  end

  def create
    @bucket = Bucket.new(bucket_params)
    @bucket.team_id = @team.id
    @bucket.row_order_position = :last

    if @bucket.save
      redirect_to team_path(@team), :notice => "Bucket was successfully created."
    else
      render :new
    end
  end

  def update
    @bucket.update(bucket_params)

    respond_to do |format|
      format.json { render :json => @bucket }
      format.html { redirect_to team_path(@team) }
    end
  end

  def destroy
    new_bucket = @team.buckets.where.not(:id => @bucket.id).last
    @bucket.issues.each {|issue| issue.move_to_bucket(new_bucket) }
    @bucket.destroy
    redirect_to team_path(@team), :notice => "Bucket was successfully destroyed."
  end

  # Archives all closed, non-archived issues for the current user.
  #
  # Note: In the future, when issues aren't limited to the user's team ID,
  # this will have to be scoped to the current team.
  def archive_closed_issues
    @team.issues.closed.where(:archived_at => nil).update_all :archived_at => Time.now

    head :ok
  end

private
  # Use callbacks to share common setup or constraints between actions.
  def set_bucket
    @bucket = @team.buckets.find(params[:id])
  end

  # Only allow a trusted parameter "white list" through.
  def bucket_params
    params.require(:bucket).permit(:name, :row_order_position)
  end
end<commit_msg>Round archived_at to minute on set<commit_after>class BucketsController < ApplicationController
  before_filter :authorize_read_team!
  before_filter :authorize_write_team!, :only => [:create, :update, :destroy, :archive_closed_issues]
  before_action :set_bucket, :only => [:edit, :update, :destroy]

  def index
    if @team.buckets.any?
      team_members
      @buckets = @team.buckets
      @columns = 12 / (@buckets.length > 0 ? @buckets.length : 1)
    elsif @team.present?
      if team_member?
        redirect_to new_team_bucket_path(@team)
      else
        redirect_to teams_path
      end
    else
      redirect_to teams_path
    end
  end

  def new
    @bucket = Bucket.new
  end

  def edit
  end

  def create
    @bucket = Bucket.new(bucket_params)
    @bucket.team_id = @team.id
    @bucket.row_order_position = :last

    if @bucket.save
      redirect_to team_path(@team), :notice => "Bucket was successfully created."
    else
      render :new
    end
  end

  def update
    @bucket.update(bucket_params)

    respond_to do |format|
      format.json { render :json => @bucket }
      format.html { redirect_to team_path(@team) }
    end
  end

  def destroy
    new_bucket = @team.buckets.where.not(:id => @bucket.id).last
    @bucket.issues.each {|issue| issue.move_to_bucket(new_bucket) }
    @bucket.destroy
    redirect_to team_path(@team), :notice => "Bucket was successfully destroyed."
  end

  # Archives all closed, non-archived issues for the current user.
  #
  # Note: In the future, when issues aren't limited to the user's team ID,
  # this will have to be scoped to the current team.
  def archive_closed_issues
    @team.issues.closed.where(:archived_at => nil).update_all :archived_at => Time.now.beginning_of_minute

    head :ok
  end

private
  # Use callbacks to share common setup or constraints between actions.
  def set_bucket
    @bucket = @team.buckets.find(params[:id])
  end

  # Only allow a trusted parameter "white list" through.
  def bucket_params
    params.require(:bucket).permit(:name, :row_order_position)
  end
end
{'fraction_non_alphanumeric': 0.09633584081533608, 'fraction_numerical': 0.001941276389225916, 'mean_word_length': 3.2018348623853212, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '1350356', 'n_tokens_mistral': 1346, 'n_tokens_neox': 1295, 'n_words': 362}