<commit_before>class User < ApplicationRecord
	has_secure_password

	has_many :photos
  has_many :memberships, foreign_key: :member_id
  has_many :groups, through: :memberships
  has_many :requested_walks, foreign_key: :requester_id, class_name: 'Walk'
  has_many :guarded_walks, foreign_key: :guardian_id, class_name: 'Walk'
	validates :username, :email, :password_digest, { presence: :true }

  def walks
    walks = { requested_walks: self.requested_walks,
              guarded_walks:   self.guarded_walks }
  end
end<commit_msg>Add #upcoming_walks and #recent_walks to User model<commit_after>class User < ApplicationRecord
	has_secure_password

	has_many :photos
  has_many :memberships, foreign_key: :member_id
  has_many :groups, through: :memberships
  has_many :requested_walks, foreign_key: :requester_id, class_name: 'Walk'
  has_many :guarded_walks, foreign_key: :guardian_id, class_name: 'Walk'
	validates :username, :email, :password_digest, { presence: :true }

  def upcoming_walks
    user_walks = walks

    upcoming_walks = {
      upcoming_requests: user_walks[:requested_walks].where(
        "walk_time < now()"
      ),
      upcoming_guards: user_walks[:guarded_walks].where( "walk_time < now()")
    }
  end

  def recent_walks
    user_walks = walks

    recent_walks = {
      recent_requests: user_walks[:requested_walks].where(
        "walk_time > now()" )
      .last(5),

      recent_guards: user_walks[:guarded_walks].where(
        "walk_time > now()" )
      .last(5)
    }
  end

  private
    def walks
      walks = { requested_walks: self.requested_walks,
                guarded_walks:   self.guarded_walks }
    end
end
{'fraction_non_alphanumeric': 0.09626955475330927, 'fraction_numerical': 0.0012033694344163659, 'mean_word_length': 3.8625730994152048, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '4779093', 'n_tokens_mistral': 591, 'n_tokens_neox': 541, 'n_words': 118}