<commit_before>module Bucketerize
  class BucketingsController < ApplicationController
    skip_before_filter :verify_authenticity_token
    #before_filter :authenticate_user!

    def index
      #begin 
        bucket_ids = params[:bucket_ids]
        resource_ids = params[:resource_ids]

        @buckets = bucket_start.find bucket_ids
        @resources = resource_start.find resource_ids
        render json: {
          action: "replace_buckets",
          result: {
            resource_ids: resource_ids,
            buckets: @buckets.map do |bucket|
              {
                id: bucket.id.to_s,
                name: bucket.name,
                desc: bucket.desc
              }
            end
          }
        }
      #rescue
        #render json: {error: "unknowns"}, status: 500
      #end
    end

    def create
      #begin
        bucket_ids = params[:bucket_ids]
        resource_ids = params[:resource_ids]

        if bucket_ids.blank?
          @bucket = current_user.buckets.where(name: '默认').first_or_create
          @resources = resource_start.find resource_ids
          @resources.each do |resource|
            @bucket.add_resource resource
          end
          @buckets = [@bucket]
        else
          @buckets = bucket_start.find bucket_ids<commit_msg>bucketings controller 也使用current_user.get_default_bucket<commit_after>module Bucketerize
  class BucketingsController < ApplicationController
    skip_before_filter :verify_authenticity_token
    #before_filter :authenticate_user!

    def index
      #begin 
        bucket_ids = params[:bucket_ids]
        resource_ids = params[:resource_ids]

        @buckets = bucket_start.find bucket_ids
        @resources = resource_start.find resource_ids
        render json: {
          action: "replace_buckets",
          result: {
            resource_ids: resource_ids,
            buckets: @buckets.map do |bucket|
              {
                id: bucket.id.to_s,
                name: bucket.name,
                desc: bucket.desc
              }
            end
          }
        }
      #rescue
        #render json: {error: "unknowns"}, status: 500
      #end
    end

    def create
      #begin
        bucket_ids = params[:bucket_ids]
        resource_ids = params[:resource_ids]

        if bucket_ids.blank?
          @bucket = current_user.get_default_bucket
          @resources = resource_start.find resource_ids
          @resources.each do |resource|
            @bucket.add_resource resource
          end
          @buckets = [@bucket]
        else
          @buckets = bucket_start.find bucket_ids
{'fraction_non_alphanumeric': 0.07404580152671755, 'fraction_numerical': 0.0022900763358778627, 'mean_word_length': 1.8458197611292073, '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': '1785528', 'n_tokens_mistral': 742, 'n_tokens_neox': 703, 'n_words': 152}