<commit_before>class FantasyPlayer < ActiveRecord::Base
  has_many :fantasy_teams, through: :roster_positions
  has_many :final_rankings, dependent: :destroy
  has_many :roster_positions, dependent: :destroy
  has_many :roster_transactions, through: :transaction_line_items
  has_many :transaction_line_items
  has_many :transaction_line_item_details
  belongs_to :sports_league

  validates :name, presence: true

  def self.by_name
    order(:name)
  end

  def self.select_fantasy_player_columns
    select("fantasy_players.id, fantasy_players.name AS fantasy_player_name")
  end

  def with_rank
    unless final_rankings.empty?
      final_rankings.last.rank
    else
      '-'
    end
  end

  def with_points
    unless final_rankings.empty?<commit_msg>Adds with details class method to FantasyPlayer model Provides left join methods for final rankings and sports league<commit_after>class FantasyPlayer < ActiveRecord::Base
  has_many :fantasy_teams, through: :roster_positions
  has_many :final_rankings, dependent: :destroy
  has_many :roster_positions, dependent: :destroy
  has_many :roster_transactions, through: :transaction_line_items
  has_many :transaction_line_items
  has_many :transaction_line_item_details
  belongs_to :sports_league

  validates :name, presence: true

  def self.with_details
    with_final_rankings.with_sports_league.select_fantasy_player_columns
  end

  def self.with_final_rankings
    joins("LEFT OUTER JOIN final_rankings
      ON final_rankings.fantasy_player_id = fantasy_players.id").
      merge(FinalRanking.select_final_ranking_columns)
  end

  def self.with_sports_league
    joins("LEFT OUTER JOIN sports_leagues
        ON sports_leagues.id = fantasy_players.sports_league_id").
      merge(SportsLeague.select_sports_league_columns)
  end

  def self.by_name
    order(:name)
  end

  def self.select_fantasy_player_columns
    select("fantasy_players.id, fantasy_players.name AS fantasy_player_name")
  end

  def with_rank
    unless final_rankings.empty?
      final_rankings.last.rank
    else
      '-'
    end
  end

  def with_points
    unless final_rankings.empty?
{'fraction_non_alphanumeric': 0.05868544600938967, 'fraction_numerical': 0.0, 'mean_word_length': 4.637566137566138, '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': '4910525', 'n_tokens_mistral': 710, 'n_tokens_neox': 671, 'n_words': 146}