<commit_before>class ClientDataController < ApplicationController

  before_filter :ensure_person_login
  before_filter :ensure_client_login
  before_filter :authorize
  before_filter :get_or_create

=begin rapidoc
access:: Self
return_code:: 200
json:: { "entry":
  { "foo": 1,
    "bar": "baz" }  }
description:: Gets every key-value pair that has been saved for this user by this application.
=end
  def show
    render_json :entry => @set and return
  end

=begin rapidoc
access:: Self
return_code:: 200
json:: { "entry":
  { "foo": 1,
    "bar": "baz" }  }
param:: data
  param:: any_key - any value
  param:: any_other_key - any other value
description:: Adds new key-value pairs about this user. Any previous data with the same key
(or keys) is overwritten with the data provided.
=end
  def update
    @set.update_attributes({ :data => params[:data] })
    render_json :entry => @set and return
  end

  private

  def get_or_create
      @set = ClientDataSet.find(:first, :conditions => { :client_id => @client.id, :person_id => @user.id }) ||
             ClientDataSet.new(:client => @client, :person => @user)<commit_msg>Temporary amend in attempt to enable rapidoc generation<commit_after>class ClientDataController < ApplicationController

  before_filter :ensure_person_login
  before_filter :ensure_client_login
  before_filter :authorize
  before_filter :get_or_create

=begin rapidoc
access:: Self
return_code:: 200
description:: Gets every key-value pair that has been saved for this user by this application.
=end
  def show
    render_json :entry => @set and return
  end

=begin rapidoc
access:: Self
return_code:: 200
param:: data
  param:: any_key - any value
  param:: any_other_key - any other value
description:: Adds new key-value pairs about this user. Any previous data with the same key
(or keys) is overwritten with the data provided.
=end
  def update
    @set.update_attributes({ :data => params[:data] })
    render_json :entry => @set and return
  end

  private

  def get_or_create
      @set = ClientDataSet.find(:first, :conditions => { :client_id => @client.id, :person_id => @user.id }) ||
             ClientDataSet.new(:client => @client, :person => @user)
{'fraction_non_alphanumeric': 0.10363636363636364, 'fraction_numerical': 0.006363636363636364, 'mean_word_length': 4.118604651162791, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 19, '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': '7647121', 'n_tokens_mistral': 677, 'n_tokens_neox': 656, 'n_words': 232}