<commit_before>#
# Location update event. This is event type is required for
# all implementations
#
class LocationUpdateEvent < AssetEvent
      
  # Callbacks
  after_initialize :set_defaults
      
  # Associations
  
  # Each event has a location_id and a location description 
  belongs_to  :location,  :class_name => 'SupportFacility', :foreign_key => :location_id
      
  validates   :location_id, :presence => true
      
  #------------------------------------------------------------------------------
  # Scopes
  #------------------------------------------------------------------------------
  # set the default scope
  default_scope { where(:asset_event_type_id => AssetEventType.find_by_class_name(self.name).id).order(:event_date) }
    
  # List of hash parameters allowed by the controller
  FORM_PARAMS = [
    :location_id
  ]
  
  #------------------------------------------------------------------------------
  #
  # Class Methods
  #
  #------------------------------------------------------------------------------
    
  def self.allowable_params
    FORM_PARAMS
  end
    
  #returns the asset event type for this type of event
  def self.asset_event_type
    AssetEventType.find_by_class_name(self.name)
  end

  #------------------------------------------------------------------------------
  #
  # Instance Methods
  #
  #------------------------------------------------------------------------------

  # This must be overriden otherwise a stack error will occur  
  def get_update
    location.name unless location.nil?
  end

  protected
  
  # Set resonable defaults for a new condition update event
  def set_defaults
    super
    typed_asset = Asset.get_typed_asset(asset)
    self.location = typed_asset.location
    self.asset_event_type ||= AssetEventType.find_by_class_name(self.name)
  end    
  
end<commit_msg>[Fixes#80401790] Fixes issue with 500 error when loading a location update eevent.<commit_after>#
# Location update event. This is event type is required for
# all implementations
#
class LocationUpdateEvent < AssetEvent
      
  # Callbacks
  after_initialize :set_defaults
      
  # Associations
  
  # Each event has a location_id and a location description 
  belongs_to  :location,  :class_name => 'SupportFacility', :foreign_key => :location_id
      
  validates   :location_id, :presence => true
      
  #------------------------------------------------------------------------------
  # Scopes
  #------------------------------------------------------------------------------
  # set the default scope
  default_scope { where(:asset_event_type_id => AssetEventType.find_by_class_name(self.name).id).order(:event_date) }
    
  # List of hash parameters allowed by the controller
  FORM_PARAMS = [
    :location_id
  ]
  
  #------------------------------------------------------------------------------
  #
  # Class Methods
  #
  #------------------------------------------------------------------------------
    
  def self.allowable_params
    FORM_PARAMS
  end
    
  #returns the asset event type for this type of event
  def self.asset_event_type
    AssetEventType.find_by_class_name(self.name)
  end

  #------------------------------------------------------------------------------
  #
  # Instance Methods
  #
  #------------------------------------------------------------------------------

  # This must be overriden otherwise a stack error will occur  
  def get_update
    location.name unless location.nil?
  end

  protected
  
  # Set resonable defaults for a new condition update event
  def set_defaults
    super
    typed_asset = Asset.get_typed_asset(asset)
    self.location ||= typed_asset.location
    self.asset_event_type ||= AssetEventType.find_by_class_name(self.name)
  end    
  
end
{'fraction_non_alphanumeric': 0.29764736981231826, 'fraction_numerical': 0.002907745175786413, 'mean_word_length': 1.3200490496627835, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '5267823', 'n_tokens_mistral': 950, 'n_tokens_neox': 916, 'n_words': 242}