<commit_before>require 'yodatra/models_controller'

# API controller to serve organizations
class OrganizationsController < Yodatra::ModelsController
  def read_scope
    self.class.read_scope
  end


  post '/organizations/with_admins' do
    if params[:admins_ids].blank?
      status 400
      [Errors::NO_ROUTE].to_json
    else
      organization = Organization.new(organization_params)

      if organization.save<commit_msg>feat(api/organizations): add user leave action<commit_after>require 'yodatra/models_controller'

# API controller to serve organizations
class OrganizationsController < Yodatra::ModelsController

  disable :delete

  def read_scope
    self.class.read_scope
  end

  delete '/organizations/:id/user/:user_id' do
    organization = Organization.find params[:id]
    user = User.find params[:user_id]

    if organization.nil? || user.nil?
      status 400
      [Errors::BAD_REQUEST].to_json
    else
      teams = Team.where(organization: organization)

      UserRole.destroy_all(:team => teams, user: user)
      status 200
      'ok'.to_json
    end
  end

  post '/organizations/with_admins' do
    if params[:admins_ids].blank?
      status 400
      [Errors::NO_ROUTE].to_json
    else
      organization = Organization.new(organization_params)

      if organization.save
{'fraction_non_alphanumeric': 0.0855614973262032, 'fraction_numerical': 0.009167303284950344, 'mean_word_length': 3.5644599303135887, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '2223998', 'n_tokens_mistral': 401, 'n_tokens_neox': 376, 'n_words': 87}