<commit_before># frozen_string_literal: true

# rubocop:disable Metrics/BlockLength
namespace :lighthouse_sample_table do
  desc 'Update lighthouse_sample with cog uk ids from sample'

  # For each positive Lighthouse Sample row, set the Cog UK ID from the matching Sample
  task update_lighthouse_sample_cog_uk_ids: :environment do
    rows_found = 0
    rows_already_set = 0
    rows_no_sample_found = 0
    rows_sample_had_no_cog_uk_id = 0
    rows_updated = 0

    STDOUT.puts('Updating lighthouse sample table with cog uk ids')

    # only select positives, as only positives have cog_uk_ids
    LighthouseSample.where(result: 'positive').each do |lh_sample|
      puts ("Starting looping through the positives") if rows_found == 0
      rows_found += 1
      puts ("On row #{rows_found}") if rows_found % 100 == 0

      # skip if cog_uk_id already set
      if lh_sample.cog_uk_id.present?
        rows_already_set += 1
        next
      end

      # fetch cog_uk_id from sample where root_sample_id and result match, and
      # joining via stock_resource to match on plate_barcode and coordinate<commit_msg>rubocop<commit_after># frozen_string_literal: true

# rubocop:disable Metrics/BlockLength
namespace :lighthouse_sample_table do
  desc 'Update lighthouse_sample with cog uk ids from sample'

  # For each positive Lighthouse Sample row, set the Cog UK ID from the matching Sample
  task update_lighthouse_sample_cog_uk_ids: :environment do
    rows_found = 0
    rows_already_set = 0
    rows_no_sample_found = 0
    rows_sample_had_no_cog_uk_id = 0
    rows_updated = 0

    STDOUT.puts('Updating lighthouse sample table with cog uk ids')

    # only select positives, as only positives have cog_uk_ids
    LighthouseSample.where(result: 'positive').each do |lh_sample|
      puts 'Starting looping through the positives' if rows_found.zero?
      rows_found += 1
      puts "On row #{rows_found}" if (rows_found % 100).zero?

      # skip if cog_uk_id already set
      if lh_sample.cog_uk_id.present?
        rows_already_set += 1
        next
      end

      # fetch cog_uk_id from sample where root_sample_id and result match, and
      # joining via stock_resource to match on plate_barcode and coordinate
{'fraction_non_alphanumeric': 0.05565529622980251, 'fraction_numerical': 0.009874326750448833, 'mean_word_length': 3.57700205338809, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3397090', 'n_tokens_mistral': 736, 'n_tokens_neox': 680, 'n_words': 227}