<commit_before>class LockVersion < ApplicationRecord
  include Version
  belongs_to :target, polymorphic: true

  after_save do
    item = lock_version_target
    item.update_column(:stale_lock_version, number) if item && number > item.stale_lock_version
  end

  def self.join_content_items(content_item_scope)
    content_item_scope.joins(
      "INNER JOIN lock_versions ON
        lock_versions.target_id = content_items.id AND<commit_msg>Support stale_lock_version being nil on populating<commit_after>class LockVersion < ApplicationRecord
  include Version
  belongs_to :target, polymorphic: true

  after_save do
    item = lock_version_target
    next unless item
    item.update_column(:stale_lock_version, number) if number > (item.stale_lock_version || -1)
  end

  def self.join_content_items(content_item_scope)
    content_item_scope.joins(
      "INNER JOIN lock_versions ON
        lock_versions.target_id = content_items.id AND
{'fraction_non_alphanumeric': 0.05826271186440678, 'fraction_numerical': 0.001059322033898305, 'mean_word_length': 4.5588235294117645, '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': '5255251', 'n_tokens_mistral': 294, 'n_tokens_neox': 282, 'n_words': 67}