<commit_before>class GroupsController < ApplicationController

  # Create a Group
  # https://github.com/cloudfoundry/uaa/blob/master/docs/UAA-APIs.rst#create-a-group-post-group
  post '/?' do
    group = Group.new
    set_group_details group, read_json_body
    if group.save
      return 201, group_hash(group).to_json
    else
      handle_save_error group
    end
  end

  # Get a specific Group by guid
  get '/:id' do
    id = params[:id]
    group = Group.find_by_guid(id)
    raise Aok::Errors::ScimNotFound.new("Group #{id} does not exist") \
      unless group
    group_hash(group).to_json
  end

  # Update a Group
  # https://github.com/cloudfoundry/uaa/blob/master/docs/UAA-APIs.rst#update-a-group-patch-groupid
  patch '/:id' do
    # XXX check that user is not already in group
    group = Group.find_by_guid(params[:id])
    read_json_body['members'].each do |user|
      user_guid = user['value']
      identity = Identity.find_by_guid(user_guid)
      if user['operation'] && user['operation'].downcase == 'delete'<commit_msg>Remove unneeded comment<commit_after>class GroupsController < ApplicationController

  # Create a Group
  # https://github.com/cloudfoundry/uaa/blob/master/docs/UAA-APIs.rst#create-a-group-post-group
  post '/?' do
    group = Group.new
    set_group_details group, read_json_body
    if group.save
      return 201, group_hash(group).to_json
    else
      handle_save_error group
    end
  end

  # Get a specific Group by guid
  get '/:id' do
    id = params[:id]
    group = Group.find_by_guid(id)
    raise Aok::Errors::ScimNotFound.new("Group #{id} does not exist") \
      unless group
    group_hash(group).to_json
  end

  # Update a Group
  # https://github.com/cloudfoundry/uaa/blob/master/docs/UAA-APIs.rst#update-a-group-patch-groupid
  patch '/:id' do
    group = Group.find_by_guid(params[:id])
    read_json_body['members'].each do |user|
      user_guid = user['value']
      identity = Identity.find_by_guid(user_guid)
      if user['operation'] && user['operation'].downcase == 'delete'
{'fraction_non_alphanumeric': 0.1224390243902439, 'fraction_numerical': 0.002926829268292683, 'mean_word_length': 3.3178947368421055, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '5373478', 'n_tokens_mistral': 699, 'n_tokens_neox': 679, 'n_words': 144}