<commit_before>class User < ActiveRecord::Base
  belongs_to :district
  has_many :candidates
  has_many :endorsements

  has_one :organization
  has_many :watchings
  has_one :twitter

  #top users to watch in user specific district calculation
  def watched_users_score
    endorsements = self.endorsements
    followers = self.twitter.followers
    if followers == false
    sum_score = endorsements.compact.count
    else
    sum_score = endorsements.compact.count + followers.compact.count
    end
  end

  #checks that the listed users to watch are only those users that are not already endorsed by the viewer
  def check_watched_users
  end


  #top watch users suggestions for a specific user
  def home_login_users_to_watch
    districts_for_user = self.district.add_parents
    user_score = {}
    users = User.all
    test_array_of_scores = users.map { |user| user.users_score}
  end

  def candidates_score
  end

  def check_candidates
  end

  #top candidate suggestions for a specific user
  def home_login_candidates_to_endorse

  end
<commit_msg>add home_watched_users sorted and filtered by district<commit_after>class User < ActiveRecord::Base
  belongs_to :district
  has_many :candidates
  has_many :endorsements

  has_one :organization
  has_many :watchings
  has_one :twitter

  #top users to watch in user specific district calculation
  def home_watched_users_score
    if self.twitter == nil || self.twitter.followers == nil || self.twitter.followers == [] || self.endorsements == [] #FL double checked these. However are there more eventualities?
      sum_score = 1
    else
      endorsements = self.endorsements.map { |endorsement| endorsement }
      followers = self.twitter.followers.map { |follower| follower }
      sum_score = endorsements.compact.count + followers.compact.count
    end
  end

  #checks that the listed users to watch are only those users that are not already watched by the viewer
  def home_check_watched_users
  end

  #check that all information is district specific
  def acceptable_district_watched_users
    districts_for_user = self.district.add_parents
    district_for_user_array = districts_for_user.map {|district| district.id}
  end

  #returns all users
  def users
    users_collection = User.all
  end

  #top watch users suggestions for a specific user
  def home_login_users_to_watch
    users_array = users.map {|user| user}
    users_array = users_array.sort_by {|user| user.home_watched_users_score}
    specific_district_user_array = users_array.select {|user| acceptable_district_watched_users.include?(user.district_id)}
    # cut_off_users_array = specific_district_user_array[0..10]
  end

  #top candidates to endorse in user specific district calculation
  def home_candidates_score
  end

  #checks that the listed candidates are only those candidates that are not already endorsed by the viewer
  def home_check_candidates
  end

  #top candidate suggestions for a specific user
  def home_login_candidates_to_endorse

  end

{'fraction_non_alphanumeric': 0.05250913924891991, 'fraction_numerical': 0.0013293452974410102, 'mean_word_length': 4.093062605752961, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '3467840', 'n_tokens_mistral': 916, 'n_tokens_neox': 863, 'n_words': 276}