<commit_before>class FlickrPhoto < Photo
  
  Photo.descendent_classes ||= []
  Photo.descendent_classes << self
  
  validates_presence_of :native_photo_id
    
  def validate
    # Check to make sure the user owns the flickr photo
    if self.user && self.api_response
      if self.api_response.is_a?(Net::Flickr::Photo)
        fp_flickr_user_id = self.api_response.owner
      else
        fp_flickr_user_id = self.api_response.owner.nsid
      end
      
      if user.flickr_identity.blank? || fp_flickr_user_id != user.flickr_identity.flickr_user_id
        errors.add(:user, "must own the photo on Flickr.")
      end
    end
  end
  
  def self.get_api_response(native_photo_id, options = {})
    flickr = Net::Flickr.authorize(FLICKR_API_KEY, FLICKR_SHARED_SECRET)
    if options[:user] && options[:user].flickr_identity
      flickr.auth.token = options[:user].flickr_identity.token
    end
    flickr.photos.get_info(native_photo_id)
  end
  
  def self.new_from_api_response(api_response, options = {})
    logger.debug "[DEBUG] api_response.class: #{api_response.class}"
    if api_response.is_a? Net::Flickr::Photo
      new_from_net_flickr(api_response, options)
    else
      new_from_flickraw(api_response, options)
    end
  end
  <commit_msg>Trying to log around a bug.<commit_after>class FlickrPhoto < Photo
  
  Photo.descendent_classes ||= []
  Photo.descendent_classes << self
  
  validates_presence_of :native_photo_id
    
  def validate
    # Check to make sure the user owns the flickr photo
    if self.user && self.api_response
      if self.api_response.is_a?(Net::Flickr::Photo)
        fp_flickr_user_id = self.api_response.owner
      else
        fp_flickr_user_id = self.api_response.owner.nsid
      end
      
      if user.flickr_identity.blank? || fp_flickr_user_id != user.flickr_identity.flickr_user_id
        errors.add(:user, "must own the photo on Flickr.")
      end
    end
  end
  
  def self.get_api_response(native_photo_id, options = {})
    flickr = Net::Flickr.authorize(FLICKR_API_KEY, FLICKR_SHARED_SECRET)
    if options[:user] && options[:user].flickr_identity
      flickr.auth.token = options[:user].flickr_identity.token
    end
    flickr.photos.get_info(native_photo_id)
  rescue Net::Flickr::APIError => e
    if options.blank?
      Rails.logger.error "[ERROR #{Time.now}] Net::Flickr had an auth " + 
        "token when it shouldn't: #{flickr.auth.inspect}"
    end
    raise e
  end
  
  def self.new_from_api_response(api_response, options = {})
    logger.debug "[DEBUG] api_response.class: #{api_response.class}"
    if api_response.is_a? Net::Flickr::Photo
      new_from_net_flickr(api_response, options)
    else
      new_from_flickraw(api_response, options)
    end
  end
  
{'fraction_non_alphanumeric': 0.09625862695241555, 'fraction_numerical': 0.0, 'mean_word_length': 3.3507109004739335, 'pattern_counts': {'":': 0, '<': 9, '<?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': '1430770', 'n_tokens_mistral': 972, 'n_tokens_neox': 943, 'n_words': 177}