<commit_before>class OauthToken < ActiveRecord::Base
  belongs_to :client_application
  belongs_to :user
  validates_uniqueness_of :token
  validates_presence_of :client_application,:token,:secret
  before_validation_on_create :generate_keys
  
  def invalidated?
    invalidated_at!=nil
  end
  
  def invalidate!
    update_attribute(:invalidated_at,Time.now)
  end
  
  def authorized?
    authorized_at!=nil && !invalidated?
  end
  
  def to_query
    "oauth_token=#{token}&oauth_token_secret=#{secret}"
  end
    
  protected
  
  def generate_keys
    @oauth_token=client_application.oauth_server.generate_credentials
    self.token=@<PASSWORD>[0]
    self.secret=@oauth_token[1]
  end
  
end<commit_msg>use the given token/secret, if it exists<commit_after>class OauthToken < ActiveRecord::Base
  belongs_to :client_application
  belongs_to :user
  validates_uniqueness_of :token
  validates_presence_of :client_application,:token,:secret
  before_validation_on_create :generate_keys
  
  def invalidated?
    invalidated_at!=nil
  end
  
  def invalidate!
    update_attribute(:invalidated_at,Time.now)
  end
  
  def authorized?
    authorized_at!=nil && !invalidated?
  end
  
  def to_query
    "oauth_token=#{token}&oauth_token_secret=#{secret}"
  end
    
  protected
  
  def generate_keys
    @oauth_token=client_application.oauth_server.generate_credentials
    self.token ||= @oauth_token[0]
    self.secret ||= @oauth_token[1]
  end
  
end
{'fraction_non_alphanumeric': 0.0823045267489712, 'fraction_numerical': 0.0027434842249657062, 'mean_word_length': 4.484962406015038, 'pattern_counts': {'":': 0, '<': 6, '<?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': '6057019', 'n_tokens_mistral': 502, 'n_tokens_neox': 504, 'n_words': 83}