<commit_before># frozen_string_literal: true
require 'db_pyr_update'

namespace :db do
  namespace :pyr do
    namespace :update do
      desc 'Retire historical reps'
      task :retired_reps do
        if ENV['file']
          file = ENV['file']
        else
          file = Dir.glob(
            Rails.root.join('lib', 'seeds', '*legislators-historical*.y*l')
          ).last
        end
        update = DbPyrUpdate::HistoricalReps.new(file)
        update.call
      end

      desc 'Update current reps in database from yaml data file'
      task :current_reps do
        if ENV['file']
          file = ENV['file']
        else
          file = Dir.glob(
            Rails.root.join('lib', 'seeds', '*legislators-current*.y*l')
          ).last
        end
        update = DbPyrUpdate::Reps.new(file)
        update.call
      end

      desc 'Update rep social media accounts from yaml data file'
      task :socials do
        if ENV['file']
          file = ENV['file']
        else
          file = Dir.glob(
            Rails.root.join('lib', 'seeds', '*legislators-social-media*.y*l')
          ).last
        end
        update = DbPyrUpdate::Socials.new(file)
        update.call
      end

      desc 'Update office locations in database from yaml data file'
      task :office_locations do
        if ENV['file']
          file = ENV['file']
        else
          file = Dir.glob(
            Rails.root.join('lib', 'seeds', '*legislators-district-offices*.y*l')
          ).last
        end
        update = DbPyrUpdate::OfficeLocations.new(file)
        update.call
      end

      desc 'Update all rep and office_location data from default yaml files'
      task all: [:retired_reps, :current_reps, :socials, :office_locations]
    end<commit_msg>refactor<commit_after># frozen_string_literal: true
require 'db_pyr_update'

namespace :db do
  namespace :pyr do
    namespace :update do
      def get_file(*default)
        if ENV['file']
          ENV['file']
        else
          Dir.glob(
            Rails.root.join(*default)
          ).last
        end
      end

      desc 'Retire historical reps'
      task :retired_reps do
        file = get_file('lib', 'seeds', '*legislators-historical*.y*l')
        update = DbPyrUpdate::HistoricalReps.new(file)
        update.call
      end

      desc 'Update current reps in database from yaml data file'
      task :current_reps do
        file = get_file('lib', 'seeds', '*legislators-current*.y*l')
        update = DbPyrUpdate::Reps.new(file)
        update.call
      end

      desc 'Update rep social media accounts from yaml data file'
      task :socials do
        file = get_file('lib', 'seeds', '*legislators-social-media*.y*l')
        update = DbPyrUpdate::Socials.new(file)
        update.call
      end

      desc 'Update office locations in database from yaml data file'
      task :office_locations do
        file = get_file('lib', 'seeds', '*legislators-district-offices*.y*l')
        update = DbPyrUpdate::OfficeLocations.new(file)
        update.call
      end

      desc 'Update all rep and office_location data from default yaml files'
      task all: [:retired_reps, :current_reps, :socials, :office_locations]
    end
{'fraction_non_alphanumeric': 0.10421836228287841, 'fraction_numerical': 0.0, 'mean_word_length': 2.1039461020211743, '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': '1325676', 'n_tokens_mistral': 1021, 'n_tokens_neox': 964, 'n_words': 262}