<commit_before>class LocalTransaction < Publication
  embeds_many   :editions,  class_name: 'LocalTransactionEdition', inverse_of: :local_transaction
  referenced_in :lgsl,      class_name: "LocalTransactionsSource::Lgsl"

  field         :lgsl_code, type: String

  validates_presence_of :lgsl_code
  validates_presence_of :lgsl, :on => :create

  set_callback :validation, :before do |local_transaction|
    unless local_transaction.persisted?
      local_transaction.lgsl = LocalTransactionsSource.find_current_lgsl(local_transaction.lgsl_code)
    end
  end

  def self.edition_class
    LocalTransactionEdition
  end

  def verify_snac(snac)
    !lgsl.authorities.where(snac: snac).empty?
  end
end<commit_msg>Don't try and find local transaction details if we don't have an LGSL code<commit_after>class LocalTransaction < Publication
  embeds_many   :editions,  class_name: 'LocalTransactionEdition', inverse_of: :local_transaction
  referenced_in :lgsl,      class_name: "LocalTransactionsSource::Lgsl"

  field         :lgsl_code, type: String

  validates_presence_of :lgsl_code
  validates_presence_of :lgsl, :on => :create

  set_callback :validation, :before do |local_transaction|
    unless local_transaction.persisted? or lgsl_code.blank?
      local_transaction.lgsl = LocalTransactionsSource.find_current_lgsl(local_transaction.lgsl_code)
    end
  end

  def self.edition_class
    LocalTransactionEdition
  end

  def verify_snac(snac)
    !lgsl.authorities.where(snac: snac).empty?
  end
end
{'fraction_non_alphanumeric': 0.07279947054930509, 'fraction_numerical': 0.0, 'mean_word_length': 4.929411764705883, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5807693', 'n_tokens_mistral': 497, 'n_tokens_neox': 481, 'n_words': 102}