<commit_before>class LotOpenFields < ActiveRecord::Migration
  def change
    change_table :lots do |t|
      t.date    :open_date
      t.decimal :open_price, precision: 12, scale: 4
    end

    execute <<-SQL
      UPDATE lots l
         SET open_date  = t.date
           , open_price = t.price
        FROM (SELECT DISTINCT ON (lot_id)
                     lot_id
                   , date
                   , price
                FROM transactions
               ORDER BY lot_id, date DESC) t
       WHERE t.lot_id = l.id
    SQL
  end
end<commit_msg>Order by correct direction<commit_after>class LotOpenFields < ActiveRecord::Migration
  def change
    change_table :lots do |t|
      t.date    :open_date
      t.decimal :open_price, precision: 12, scale: 4
    end

    execute <<-SQL
      UPDATE lots l
         SET open_date  = t.date
           , open_price = t.price
        FROM (SELECT DISTINCT ON (lot_id)
                     lot_id
                   , date
                   , price
                FROM transactions
               ORDER BY lot_id, date) t
       WHERE t.lot_id = l.id
    SQL
  end
end
{'fraction_non_alphanumeric': 0.06216696269982238, 'fraction_numerical': 0.0053285968028419185, 'mean_word_length': 1.4236559139784946, 'pattern_counts': {'":': 0, '<': 9, '<?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': '2880013', 'n_tokens_mistral': 346, 'n_tokens_neox': 323, 'n_words': 101}