<commit_before>class ShipsStation < ActiveRecord::Base

  belongs_to :ship
  belongs_to :station

  def get_time_since_upgrade
    return (Time.now - self.updated_at).to_i
  end

  def get_upgrade_ratio
    duration = self.station.get_duration(self.level).to_f
    past = self.get_time_since_upgrade.to_f
    return 1.0 - (past/duration).to_f
  end

  def get_refund
    station = self.station
    currentLevel = self.level

    ratio = self.get_upgrade_ratio
    reMetal = station.get_metal_cost_ratio(currentLevel, ratio)
    reCrystal = station.get_crystal_cost_ratio(currentLevel, ratio)
    reFuel = station.get_fuel_cost_ratio(currentLevel, ratio)

    back = ""
    back = back + "Refund: <br>"
    back = back+"- Metal: "+reMetal.to_i.to_s+"<br>"
    back = back+"- Crystal: "+reCrystal.to_i.to_s+"<br>"
    back = back+"- Fuel: "+reFuel.to_i.to_s+"<br>"

    return back.html_safe
  end

  def sum_level(ship)
    sum=0
    ShipsStation.where(:ship_id => ship.id).each do |station|
      sum+=station.level
    end  
    return sum - ShipsStation.find_by(ship_id: ship.id, station_id: 2007).level
  end

  def max_station_level(ship)
    i = 5 + 10 * ShipsStation.find_by(ship_id: ship.id, station_id: 2007).level
    return i
  end


  def get_conditions()
  	info = self.station.condition
  	conds = info.split(",")<commit_msg>Bauplätze auf richtige Zahl geändert<commit_after>class ShipsStation < ActiveRecord::Base

  belongs_to :ship
  belongs_to :station

  def get_time_since_upgrade
    return (Time.now - self.updated_at).to_i
  end

  def get_upgrade_ratio
    duration = self.station.get_duration(self.level).to_f
    past = self.get_time_since_upgrade.to_f
    return 1.0 - (past/duration).to_f
  end

  def get_refund
    station = self.station
    currentLevel = self.level

    ratio = self.get_upgrade_ratio
    reMetal = station.get_metal_cost_ratio(currentLevel, ratio)
    reCrystal = station.get_crystal_cost_ratio(currentLevel, ratio)
    reFuel = station.get_fuel_cost_ratio(currentLevel, ratio)

    back = ""
    back = back + "Refund: <br>"
    back = back+"- Metal: "+reMetal.to_i.to_s+"<br>"
    back = back+"- Crystal: "+reCrystal.to_i.to_s+"<br>"
    back = back+"- Fuel: "+reFuel.to_i.to_s+"<br>"

    return back.html_safe
  end

  def sum_level(ship)
    sum=0
    ShipsStation.where(:ship_id => ship.id).each do |station|
      sum+=station.level
    end  
    return sum - ShipsStation.find_by(ship_id: ship.id, station_id: 2007).level
  end

  def max_station_level(ship)
    i = 100 + 10 * ShipsStation.find_by(ship_id: ship.id, station_id: 2007).level
    return i
  end


  def get_conditions()
  	info = self.station.condition
  	conds = info.split(",")
{'fraction_non_alphanumeric': 0.11403184005923732, 'fraction_numerical': 0.011106997408367271, 'mean_word_length': 3.4514003294892914, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '488349', 'n_tokens_mistral': 1042, 'n_tokens_neox': 974, 'n_words': 191}