From 425e834b2be8332cff739c3e3bac6aee753015af Mon Sep 17 00:00:00 2001 From: moveson Date: Sun, 22 Dec 2024 03:52:06 -0700 Subject: [PATCH] Change capitalization of Etl and Html to make zeitwerk happy --- .../api/v1/event_groups_controller.rb | 4 +-- app/controllers/api/v1/events_controller.rb | 6 ++-- app/controllers/import_jobs_controller.rb | 4 +-- app/jobs/import_async_job.rb | 4 +-- app/models/proto_record.rb | 4 +-- config/application.rb | 2 ++ .../action_view/helpers/url_helper.rb | 3 +- lib/etl.rb | 34 +++++++++++++++++++ lib/etl/async_importer.rb | 12 +++---- lib/etl/csv_templates.rb | 2 +- lib/etl/errors.rb | 2 +- lib/etl/etl.rb | 34 ------------------- lib/etl/event_group_import_process.rb | 2 +- lib/etl/event_import_process.rb | 2 +- lib/etl/extractor.rb | 2 +- .../extractors/adilas_bear_html_strategy.rb | 6 ++-- lib/etl/extractors/csv_file_strategy.rb | 4 +-- .../extractors/its_your_race_html_strategy.rb | 6 ++-- lib/etl/extractors/pass_through_strategy.rb | 4 +-- .../extractors/race_result_api_strategy.rb | 4 +-- lib/etl/extractors/race_result_strategy.rb | 4 +-- .../helpers/race_result_api_uri_builder.rb | 2 +- lib/etl/helpers/race_result_uri_builder.rb | 2 +- lib/etl/importer.rb | 16 ++++----- lib/etl/importer_from_context.rb | 4 +-- lib/etl/loader.rb | 2 +- lib/etl/loaders/async/insert_strategy.rb | 4 +-- .../ultrasignup_order_id_compare_strategy.rb | 4 +-- lib/etl/loaders/base_loader.rb | 4 +-- lib/etl/loaders/insert_strategy.rb | 2 +- lib/etl/loaders/split_time_upsert_strategy.rb | 2 +- lib/etl/loaders/upsert_strategy.rb | 2 +- lib/etl/transformable.rb | 2 +- lib/etl/transformer.rb | 2 +- lib/etl/transformers/adilas_bear_strategy.rb | 2 +- .../async/efforts_with_times_strategy.rb | 4 +-- .../hardrock_historical_facts_strategy.rb | 4 +-- .../async/historical_facts_strategy.rb | 4 +-- lib/etl/transformers/async/null_strategy.rb | 4 +-- .../ultrasignup_historical_facts_strategy.rb | 4 +-- lib/etl/transformers/base_transformer.rb | 4 +-- .../elapsed_incremental_aid_strategy.rb | 2 +- .../event_course_splits_strategy.rb | 2 +- .../event_group_entrants_strategy.rb | 2 +- .../generic_resources_strategy.rb | 2 +- .../transformers/jsonapi_batch_strategy.rb | 2 +- .../transformers/lottery_entrants_strategy.rb | 2 +- .../race_result_api_split_times_strategy.rb | 2 +- .../race_result_entrants_strategy.rb | 2 +- .../race_result_split_times_strategy.rb | 2 +- lib/tasks/pull_event_data.rake | 8 ++--- spec/lib/etl/async_importer_spec.rb | 4 +-- spec/lib/etl/csv_templates_spec.rb | 2 +- .../adilas_bear_html_strategy_spec.rb | 2 +- .../etl/extractors/csv_file_strategy_spec.rb | 4 +-- .../its_your_race_html_strategy_spec.rb | 2 +- .../extractors/pass_through_strategy_spec.rb | 4 +-- .../race_result_api_strategy_spec.rb | 4 +-- .../extractors/race_result_strategy_spec.rb | 4 +-- spec/lib/etl/importer_spec.rb | 4 +-- .../etl/loaders/async/insert_strategy_spec.rb | 2 +- ...rasignup_order_id_compare_strategy_spec.rb | 2 +- spec/lib/etl/loaders/insert_strategy_spec.rb | 4 +-- .../split_time_upsert_strategy_spec.rb | 14 ++++---- spec/lib/etl/loaders/upsert_strategy_spec.rb | 4 +-- .../transformers/adilas_bear_strategy_spec.rb | 4 +-- .../async/efforts_with_times_strategy_spec.rb | 2 +- ...hardrock_historical_facts_strategy_spec.rb | 2 +- .../async/historical_facts_strategy_spec.rb | 2 +- .../transformers/async/null_strategy_spec.rb | 2 +- ...rasignup_historical_facts_strategy_spec.rb | 2 +- .../elapsed_incremental_aid_strategy_spec.rb | 4 +-- .../event_group_entrants_strategy_spec.rb | 2 +- .../generic_resources_strategy_spec.rb | 4 +-- .../jsonapi_batch_strategy_spec.rb | 4 +-- .../lottery_entrants_strategy_spec.rb | 2 +- ...ce_result_api_split_times_strategy_spec.rb | 2 +- .../race_result_split_times_strategy_spec.rb | 4 +-- spec/rails_helper.rb | 1 - 79 files changed, 169 insertions(+), 169 deletions(-) create mode 100644 lib/etl.rb delete mode 100644 lib/etl/etl.rb diff --git a/app/controllers/api/v1/event_groups_controller.rb b/app/controllers/api/v1/event_groups_controller.rb index ea2861f0a..bda2a172d 100644 --- a/app/controllers/api/v1/event_groups_controller.rb +++ b/app/controllers/api/v1/event_groups_controller.rb @@ -19,14 +19,14 @@ def import authorize @resource limited_response = params[:limited_response]&.to_boolean - importer = ::ETL::ImporterFromContext.build(@resource, params, current_user) + importer = ::Etl::ImporterFromContext.build(@resource, params, current_user) importer.import errors = importer.errors + importer.invalid_records.map { |record| jsonapi_error_object(record) } if errors.present? render json: { errors: errors }, status: :unprocessable_entity else - ::ETL::EventGroupImportProcess.perform!(@resource, importer) + ::Etl::EventGroupImportProcess.perform!(@resource, importer) if limited_response render json: {}, status: :created else diff --git a/app/controllers/api/v1/events_controller.rb b/app/controllers/api/v1/events_controller.rb index 6e7713176..8e5235438 100644 --- a/app/controllers/api/v1/events_controller.rb +++ b/app/controllers/api/v1/events_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "etl/etl" +require "etl" module Api module V1 @@ -53,14 +53,14 @@ def spread end def import - importer = ::ETL::ImporterFromContext.build(@event, params, current_user) + importer = ::Etl::ImporterFromContext.build(@event, params, current_user) importer.import errors = importer.errors + importer.invalid_records.map { |record| jsonapi_error_object(record) } if errors.present? render json: {errors: errors}, status: :unprocessable_entity else - ::ETL::EventImportProcess.perform!(@event, importer) + ::Etl::EventImportProcess.perform!(@event, importer) render json: {}, status: :created end end diff --git a/app/controllers/import_jobs_controller.rb b/app/controllers/import_jobs_controller.rb index 21cb71d6b..48481ef5b 100644 --- a/app/controllers/import_jobs_controller.rb +++ b/app/controllers/import_jobs_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "etl/etl" +require "etl" class ImportJobsController < ApplicationController before_action :authenticate_user! @@ -64,7 +64,7 @@ def csv_templates format.csv do parent = params[:parent_type].constantize.find(params[:parent_id]) import_job_format = params[:import_job_format].to_sym - csv_template_headers = ::ETL::CsvTemplates.headers(import_job_format, parent) + csv_template_headers = ::Etl::CsvTemplates.headers(import_job_format, parent) csv_template = csv_template_headers.join(",") + "\n" filename_components = [import_job_format, parent.class.name.underscore, parent.id, "template.csv"] filename = filename_components.join("_") diff --git a/app/jobs/import_async_job.rb b/app/jobs/import_async_job.rb index 8025afaaf..b1c25f43e 100644 --- a/app/jobs/import_async_job.rb +++ b/app/jobs/import_async_job.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require "etl/etl" +require "etl" class ImportAsyncJob < ApplicationJob def perform(import_job_id) import_job = ImportJob.find(import_job_id) set_current_user(current_user: import_job.user) - ::ETL::AsyncImporter.import!(import_job) + ::Etl::AsyncImporter.import!(import_job) end end diff --git a/app/models/proto_record.rb b/app/models/proto_record.rb index c7cd9dead..e81de5518 100644 --- a/app/models/proto_record.rb +++ b/app/models/proto_record.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require "etl/etl" +require "etl" require "ostruct" class ProtoRecord - include ETL::Transformable + include Etl::Transformable attr_accessor :record_type, :record_action attr_reader :children, :attributes diff --git a/config/application.rb b/config/application.rb index 5e6cb84fa..f4a8e7354 100644 --- a/config/application.rb +++ b/config/application.rb @@ -38,5 +38,7 @@ class Application < Rails::Application # in config/environments, which are processed later. # # config.eager_load_paths << Rails.root.join("extras") + + Dir[Rails.root.join('lib/core_ext/**/*.rb')].each { |file| require file } end end diff --git a/lib/core_ext/action_view/helpers/url_helper.rb b/lib/core_ext/action_view/helpers/url_helper.rb index cb1b363a4..7743be57e 100644 --- a/lib/core_ext/action_view/helpers/url_helper.rb +++ b/lib/core_ext/action_view/helpers/url_helper.rb @@ -2,7 +2,6 @@ module CoreExt module UrlHelper - alias original_link_to link_to # Monkey Patch link_to to translate the boolean attribute "disabled" into a class # Using the signature (*args, &blocks) makes this patch resistant to API changes # since all args are captured as is @@ -23,6 +22,8 @@ module ActionView module Helpers module UrlHelper include CoreExt::UrlHelper + + alias original_link_to link_to end end end diff --git a/lib/etl.rb b/lib/etl.rb new file mode 100644 index 000000000..adc87a4d9 --- /dev/null +++ b/lib/etl.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module Etl +end + +require_relative "etl/csv_templates" +require_relative "etl/errors" +require_relative "etl/extractor" +require_relative "etl/transformer" +require_relative "etl/loader" +require_relative "etl/transformable" + +# Importers + +require_relative "etl/event_group_import_process" +require_relative "etl/event_import_process" +require_relative "etl/importer" +require_relative "etl/importer_from_context" +require_relative "etl/async_importer" + +# Extractors +Dir.glob("lib/etl/extractors/**/*.rb") { |file| require Rails.root.join(file) } + +# Transformers +require_relative "etl/transformers/base_transformer" +Dir.glob("lib/etl/transformers/**/*.rb") { |file| require Rails.root.join(file) } + +# Loaders + +require_relative "etl/loaders/base_loader" +Dir.glob("lib/etl/loaders/**/*.rb") { |file| require Rails.root.join(file) } + +# Helpers +Dir.glob("lib/etl/helpers/**/*.rb") { |file| require Rails.root.join(file) } diff --git a/lib/etl/async_importer.rb b/lib/etl/async_importer.rb index 4d6fe60b0..9f24598db 100644 --- a/lib/etl/async_importer.rb +++ b/lib/etl/async_importer.rb @@ -1,10 +1,8 @@ # frozen_string_literal: true -require_relative "errors" - -module ETL +module Etl class AsyncImporter - include ETL::Errors + include Etl::Errors def self.import!(import_job) new(import_job).import! @@ -81,7 +79,7 @@ def extract_data import_job.extracting! files.each do |file| import_job.set_elapsed_time! - extractor = ::ETL::Extractor.new(file, extract_strategy) + extractor = ::Etl::Extractor.new(file, extract_strategy) self.extracted_structs += extractor.extract self.errors += extractor.errors import_job.update(row_count: extracted_structs.size) @@ -92,7 +90,7 @@ def transform_data import_job.transforming! import_job.set_elapsed_time! options = { parent: parent, import_job: import_job }.merge(custom_options) - transformer = ::ETL::Transformer.new(extracted_structs, transform_strategy, options) + transformer = ::Etl::Transformer.new(extracted_structs, transform_strategy, options) self.transformed_protos = transformer.transform self.errors += transformer.errors end @@ -101,7 +99,7 @@ def load_records import_job.loading! import_job.set_elapsed_time! options = { import_job: import_job }.merge(custom_options) - loader = ::ETL::Loader.new(transformed_protos, load_strategy, options) + loader = ::Etl::Loader.new(transformed_protos, load_strategy, options) loader.load_records self.errors += loader.errors end diff --git a/lib/etl/csv_templates.rb b/lib/etl/csv_templates.rb index f7f18977f..91470010b 100644 --- a/lib/etl/csv_templates.rb +++ b/lib/etl/csv_templates.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl class CsvTemplates PERSON_ATTRIBUTES = [ "First Name", diff --git a/lib/etl/errors.rb b/lib/etl/errors.rb index 5f0870036..832413fc1 100644 --- a/lib/etl/errors.rb +++ b/lib/etl/errors.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl module Errors def bad_url_error(url, error) { title: "Bad URL", detail: { messages: ["#{url} reported an error: #{error}"] } } diff --git a/lib/etl/etl.rb b/lib/etl/etl.rb deleted file mode 100644 index 9922881ed..000000000 --- a/lib/etl/etl.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -module ETL -end - -require_relative "csv_templates" -require_relative "errors" -require_relative "extractor" -require_relative "transformer" -require_relative "loader" -require_relative "transformable" - -# Importers - -require_relative "event_group_import_process" -require_relative "event_import_process" -require_relative "importer" -require_relative "importer_from_context" -require_relative "async_importer" - -# Extractors -Dir.glob("lib/etl/extractors/**/*.rb") { |file| require Rails.root.join(file) } - -# Transformers -require_relative "transformers/base_transformer" -Dir.glob("lib/etl/transformers/**/*.rb") { |file| require Rails.root.join(file) } - -# Loaders - -require_relative "loaders/base_loader" -Dir.glob("lib/etl/loaders/**/*.rb") { |file| require Rails.root.join(file) } - -# Helpers -Dir.glob("lib/etl/helpers/**/*.rb") { |file| require Rails.root.join(file) } diff --git a/lib/etl/event_group_import_process.rb b/lib/etl/event_group_import_process.rb index 2596916a2..9488a974a 100644 --- a/lib/etl/event_group_import_process.rb +++ b/lib/etl/event_group_import_process.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl class EventGroupImportProcess def self.perform!(event_group, importer) new(event_group, importer).perform! diff --git a/lib/etl/event_import_process.rb b/lib/etl/event_import_process.rb index 7ef703aaf..aa5ea02d9 100644 --- a/lib/etl/event_import_process.rb +++ b/lib/etl/event_import_process.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl class EventImportProcess def self.perform!(event, importer) new(event, importer).perform! diff --git a/lib/etl/extractor.rb b/lib/etl/extractor.rb index a7c780522..c1ff6a005 100644 --- a/lib/etl/extractor.rb +++ b/lib/etl/extractor.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl class Extractor def initialize(source_data, extract_strategy_class, options = {}) @source_data = source_data diff --git a/lib/etl/extractors/adilas_bear_html_strategy.rb b/lib/etl/extractors/adilas_bear_html_strategy.rb index 52363c6bc..d32fc4ce6 100644 --- a/lib/etl/extractors/adilas_bear_html_strategy.rb +++ b/lib/etl/extractors/adilas_bear_html_strategy.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -module ETL +module Etl module Extractors - class AdilasBearHTMLStrategy - include ETL::Errors + class AdilasBearHtmlStrategy + include Etl::Errors attr_reader :errors def initialize(source_data, options) diff --git a/lib/etl/extractors/csv_file_strategy.rb b/lib/etl/extractors/csv_file_strategy.rb index a11c64430..7d106dc18 100644 --- a/lib/etl/extractors/csv_file_strategy.rb +++ b/lib/etl/extractors/csv_file_strategy.rb @@ -4,10 +4,10 @@ require "csv" require "ostruct" -module ETL +module Etl module Extractors class CsvFileStrategy - include ETL::Errors + include Etl::Errors MAX_FILE_SIZE = 2.megabytes BYTE_ORDER_MARK = String.new("\xEF\xBB\xBF").force_encoding("UTF-8").freeze diff --git a/lib/etl/extractors/its_your_race_html_strategy.rb b/lib/etl/extractors/its_your_race_html_strategy.rb index bc652db88..8bdef6054 100644 --- a/lib/etl/extractors/its_your_race_html_strategy.rb +++ b/lib/etl/extractors/its_your_race_html_strategy.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -module ETL +module Etl module Extractors - class ItsYourRaceHTMLStrategy - include ETL::Errors + class ItsYourRaceHtmlStrategy + include Etl::Errors attr_reader :errors def initialize(source_data, options) diff --git a/lib/etl/extractors/pass_through_strategy.rb b/lib/etl/extractors/pass_through_strategy.rb index 8c3872540..2eac0dbeb 100644 --- a/lib/etl/extractors/pass_through_strategy.rb +++ b/lib/etl/extractors/pass_through_strategy.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -module ETL +module Etl module Extractors class PassThroughStrategy - include ETL::Errors + include Etl::Errors attr_reader :errors def initialize(raw_data, options) diff --git a/lib/etl/extractors/race_result_api_strategy.rb b/lib/etl/extractors/race_result_api_strategy.rb index 92c290915..687e36661 100644 --- a/lib/etl/extractors/race_result_api_strategy.rb +++ b/lib/etl/extractors/race_result_api_strategy.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -module ETL +module Etl module Extractors class RaceResultApiStrategy NAME_WITHOUT_BIB_REGEX = /[^ #0-9\.].*/ - include ETL::Errors + include Etl::Errors attr_reader :errors def initialize(raw_data, options) diff --git a/lib/etl/extractors/race_result_strategy.rb b/lib/etl/extractors/race_result_strategy.rb index dae2db2b0..faaff5c60 100644 --- a/lib/etl/extractors/race_result_strategy.rb +++ b/lib/etl/extractors/race_result_strategy.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -module ETL +module Etl module Extractors class RaceResultStrategy - include ETL::Errors + include Etl::Errors attr_reader :errors def initialize(raw_data, options) diff --git a/lib/etl/helpers/race_result_api_uri_builder.rb b/lib/etl/helpers/race_result_api_uri_builder.rb index ddc70346e..752b416a5 100644 --- a/lib/etl/helpers/race_result_api_uri_builder.rb +++ b/lib/etl/helpers/race_result_api_uri_builder.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl module Helpers class RaceResultApiUriBuilder def initialize(rr_event_id, rr_api_key) diff --git a/lib/etl/helpers/race_result_uri_builder.rb b/lib/etl/helpers/race_result_uri_builder.rb index 31fb16e12..1a27c6694 100644 --- a/lib/etl/helpers/race_result_uri_builder.rb +++ b/lib/etl/helpers/race_result_uri_builder.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl module Helpers class RaceResultUriBuilder def initialize(rr_event_id, rr_contest_id, rr_format) diff --git a/lib/etl/importer.rb b/lib/etl/importer.rb index 8acd16a94..67b1d4d99 100644 --- a/lib/etl/importer.rb +++ b/lib/etl/importer.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -module ETL +module Etl class Importer - include ETL::Errors + include Etl::Errors REPORT_ARRAYS = [:saved_records, :invalid_records, :destroyed_records, :ignored_records, :errors].freeze attr_reader(*REPORT_ARRAYS) @@ -27,11 +27,11 @@ def import when :race_result_api_times import_with(source_data, Extractors::RaceResultApiStrategy, Transformers::RaceResultApiSplitTimesStrategy, Loaders::SplitTimeUpsertStrategy, { delete_blank_times: true }.merge(options)) when :adilas_bear_times - import_with(source_data, Extractors::AdilasBearHTMLStrategy, Transformers::AdilasBearStrategy, Loaders::InsertStrategy, options) + import_with(source_data, Extractors::AdilasBearHtmlStrategy, Transformers::AdilasBearStrategy, Loaders::InsertStrategy, options) when :adilas_bear_times_update - import_with(source_data, Extractors::AdilasBearHTMLStrategy, Transformers::AdilasBearStrategy, Loaders::SplitTimeUpsertStrategy, options) + import_with(source_data, Extractors::AdilasBearHtmlStrategy, Transformers::AdilasBearStrategy, Loaders::SplitTimeUpsertStrategy, options) when :its_your_race_times - import_with(source_data, Extractors::ItsYourRaceHTMLStrategy, Transformers::ElapsedIncrementalAidStrategy, Loaders::InsertStrategy, options) + import_with(source_data, Extractors::ItsYourRaceHtmlStrategy, Transformers::ElapsedIncrementalAidStrategy, Loaders::InsertStrategy, options) when :csv_splits import_with(source_data, Extractors::CsvFileStrategy, Transformers::GenericResourcesStrategy, Loaders::UpsertStrategy, { model: :split }.merge(default_unique_key(:split)).merge(options)) when :csv_raw_times @@ -55,17 +55,17 @@ def strict? attr_writer(*REPORT_ARRAYS) def import_with(source_data, extract_strategy, transform_strategy, load_strategy, options) - extractor = ETL::Extractor.new(source_data, extract_strategy, options) + extractor = Etl::Extractor.new(source_data, extract_strategy, options) extracted_data = extractor.extract self.errors += extractor.errors and return if extractor.errors.present? - transformer = ETL::Transformer.new(extracted_data, transform_strategy, options) + transformer = Etl::Transformer.new(extracted_data, transform_strategy, options) proto_records = transformer.transform self.errors += transformer.errors and return if transformer.errors.present? proto_record_groups = strict? ? [proto_records] : proto_records.map { |record| [record] } proto_record_groups.each do |proto_record_group| - loader = ETL::Loader.new(proto_record_group, load_strategy, options) + loader = Etl::Loader.new(proto_record_group, load_strategy, options) loader.load_records REPORT_ARRAYS.each do |report_array| loader.send(report_array).each { |report_element| send(report_array) << report_element } diff --git a/lib/etl/importer_from_context.rb b/lib/etl/importer_from_context.rb index 72a8f0c6b..5044d3ea0 100644 --- a/lib/etl/importer_from_context.rb +++ b/lib/etl/importer_from_context.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl class ImporterFromContext def self.build(parent, params, current_user) new(parent, params, current_user).build @@ -13,7 +13,7 @@ def initialize(parent, params, current_user) end def build - ETL::Importer.new(data, data_format, options) + Etl::Importer.new(data, data_format, options) end private diff --git a/lib/etl/loader.rb b/lib/etl/loader.rb index 1c2e9a70b..21c88ebcb 100644 --- a/lib/etl/loader.rb +++ b/lib/etl/loader.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl class Loader def initialize(proto_records, load_strategy_class, options) @proto_records = proto_records diff --git a/lib/etl/loaders/async/insert_strategy.rb b/lib/etl/loaders/async/insert_strategy.rb index b615a7807..e68362e66 100644 --- a/lib/etl/loaders/async/insert_strategy.rb +++ b/lib/etl/loaders/async/insert_strategy.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL::Loaders::Async +module Etl::Loaders::Async # If no unique_key is provided, this is a plain insert loader that will # keep track of errors if validations are violated at the model or database # level. @@ -8,7 +8,7 @@ module ETL::Loaders::Async # If a unique_key is provided, records having the same unique key as an existing # database record will be ignored. class InsertStrategy - include ETL::Errors + include Etl::Errors CHUNK_SIZE = 20 diff --git a/lib/etl/loaders/async/ultrasignup_order_id_compare_strategy.rb b/lib/etl/loaders/async/ultrasignup_order_id_compare_strategy.rb index caee13521..1ec177709 100644 --- a/lib/etl/loaders/async/ultrasignup_order_id_compare_strategy.rb +++ b/lib/etl/loaders/async/ultrasignup_order_id_compare_strategy.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -module ETL::Loaders::Async +module Etl::Loaders::Async # This loader does not attempt to persist records in the database. # It merely compares order ids and creates errors when differences exist. # TODO: This is a hack and should be replaced by a proper sync strategy class UltrasignupOrderIdCompareStrategy - include ETL::Errors + include Etl::Errors CHUNK_SIZE = 20 diff --git a/lib/etl/loaders/base_loader.rb b/lib/etl/loaders/base_loader.rb index eb5f1de00..6bbb9391a 100644 --- a/lib/etl/loaders/base_loader.rb +++ b/lib/etl/loaders/base_loader.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -module ETL +module Etl module Loaders class BaseLoader - include ETL::Errors + include Etl::Errors attr_reader :saved_records, :invalid_records, :destroyed_records, :ignored_records, :errors def initialize(proto_records, options) diff --git a/lib/etl/loaders/insert_strategy.rb b/lib/etl/loaders/insert_strategy.rb index f9e5261e4..236b77ce8 100644 --- a/lib/etl/loaders/insert_strategy.rb +++ b/lib/etl/loaders/insert_strategy.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl module Loaders class InsertStrategy < BaseLoader def post_initialize(options) diff --git a/lib/etl/loaders/split_time_upsert_strategy.rb b/lib/etl/loaders/split_time_upsert_strategy.rb index 7bf9839aa..683691d6c 100644 --- a/lib/etl/loaders/split_time_upsert_strategy.rb +++ b/lib/etl/loaders/split_time_upsert_strategy.rb @@ -3,7 +3,7 @@ # This strategy looks for existing efforts only and creates, updates, or deletes # split_times for those existing efforts. This strategy does not create any new efforts. -module ETL +module Etl module Loaders class SplitTimeUpsertStrategy < BaseLoader def post_initialize(_options) diff --git a/lib/etl/loaders/upsert_strategy.rb b/lib/etl/loaders/upsert_strategy.rb index 1355dfc44..16d0142ea 100644 --- a/lib/etl/loaders/upsert_strategy.rb +++ b/lib/etl/loaders/upsert_strategy.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl module Loaders class UpsertStrategy < BaseLoader def post_initialize(options) diff --git a/lib/etl/transformable.rb b/lib/etl/transformable.rb index 661132dde..1550a3f84 100644 --- a/lib/etl/transformable.rb +++ b/lib/etl/transformable.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl module Transformable def add_country_from_state_code! state_code = self[:state_code] diff --git a/lib/etl/transformer.rb b/lib/etl/transformer.rb index a70aba675..7e0530bea 100644 --- a/lib/etl/transformer.rb +++ b/lib/etl/transformer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl class Transformer def initialize(parsed_structs, transform_strategy_class, options = {}) @parsed_structs = parsed_structs diff --git a/lib/etl/transformers/adilas_bear_strategy.rb b/lib/etl/transformers/adilas_bear_strategy.rb index 172b0d443..9af240960 100644 --- a/lib/etl/transformers/adilas_bear_strategy.rb +++ b/lib/etl/transformers/adilas_bear_strategy.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl module Transformers class AdilasBearStrategy < BaseTransformer def initialize(parsed_struct, options) diff --git a/lib/etl/transformers/async/efforts_with_times_strategy.rb b/lib/etl/transformers/async/efforts_with_times_strategy.rb index e78fa698b..b11790a3c 100644 --- a/lib/etl/transformers/async/efforts_with_times_strategy.rb +++ b/lib/etl/transformers/async/efforts_with_times_strategy.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -module ETL::Transformers::Async - class EffortsWithTimesStrategy < ETL::Transformers::BaseTransformer +module Etl::Transformers::Async + class EffortsWithTimesStrategy < Etl::Transformers::BaseTransformer DEFAULT_START_KEY = "start" DEFAULT_TIME_FORMAT = :elapsed TIME_ATTRIBUTE_MAP = { diff --git a/lib/etl/transformers/async/hardrock_historical_facts_strategy.rb b/lib/etl/transformers/async/hardrock_historical_facts_strategy.rb index e753734a3..fbac5a681 100644 --- a/lib/etl/transformers/async/hardrock_historical_facts_strategy.rb +++ b/lib/etl/transformers/async/hardrock_historical_facts_strategy.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -module ETL::Transformers::Async - class HardrockHistoricalFactsStrategy < ETL::Transformers::BaseTransformer +module Etl::Transformers::Async + class HardrockHistoricalFactsStrategy < Etl::Transformers::BaseTransformer JUNK_PREVIOUS_NAMES = ["no", "n", "n/a", "na", "none"].freeze PRIOR_YEARS = (1992..2024).to_a.map { |year| year.to_s.to_sym }.freeze PRIOR_YEAR_OUTCOMES = { diff --git a/lib/etl/transformers/async/historical_facts_strategy.rb b/lib/etl/transformers/async/historical_facts_strategy.rb index 10c05616a..4c77273c7 100644 --- a/lib/etl/transformers/async/historical_facts_strategy.rb +++ b/lib/etl/transformers/async/historical_facts_strategy.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -module ETL::Transformers::Async - class HistoricalFactsStrategy < ETL::Transformers::BaseTransformer +module Etl::Transformers::Async + class HistoricalFactsStrategy < Etl::Transformers::BaseTransformer def initialize(parsed_structs, options) @proto_records = parsed_structs.map { |struct| ProtoRecord.new(struct) } @options = options diff --git a/lib/etl/transformers/async/null_strategy.rb b/lib/etl/transformers/async/null_strategy.rb index bb0f2b33d..820d08186 100644 --- a/lib/etl/transformers/async/null_strategy.rb +++ b/lib/etl/transformers/async/null_strategy.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -module ETL::Transformers::Async - class NullStrategy < ETL::Transformers::BaseTransformer +module Etl::Transformers::Async + class NullStrategy < Etl::Transformers::BaseTransformer def initialize(parsed_structs, options) @parsed_structs = parsed_structs @options = options diff --git a/lib/etl/transformers/async/ultrasignup_historical_facts_strategy.rb b/lib/etl/transformers/async/ultrasignup_historical_facts_strategy.rb index 29cf4e81c..8e7e86adc 100644 --- a/lib/etl/transformers/async/ultrasignup_historical_facts_strategy.rb +++ b/lib/etl/transformers/async/ultrasignup_historical_facts_strategy.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -module ETL::Transformers::Async - class UltrasignupHistoricalFactsStrategy < ETL::Transformers::BaseTransformer +module Etl::Transformers::Async + class UltrasignupHistoricalFactsStrategy < Etl::Transformers::BaseTransformer JUNK_VALUES = ["no", "n", "n/a", "na", "none"].freeze PRIOR_YEAR_OUTCOMES = { dns: :dns, diff --git a/lib/etl/transformers/base_transformer.rb b/lib/etl/transformers/base_transformer.rb index e163cf56a..bc5bc04f1 100644 --- a/lib/etl/transformers/base_transformer.rb +++ b/lib/etl/transformers/base_transformer.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -module ETL +module Etl module Transformers class BaseTransformer - include ETL::Errors + include Etl::Errors attr_reader :errors private diff --git a/lib/etl/transformers/elapsed_incremental_aid_strategy.rb b/lib/etl/transformers/elapsed_incremental_aid_strategy.rb index de3ea052d..27d9d08d7 100644 --- a/lib/etl/transformers/elapsed_incremental_aid_strategy.rb +++ b/lib/etl/transformers/elapsed_incremental_aid_strategy.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl module Transformers class ElapsedIncrementalAidStrategy < BaseTransformer def initialize(parsed_struct, options) diff --git a/lib/etl/transformers/event_course_splits_strategy.rb b/lib/etl/transformers/event_course_splits_strategy.rb index 66ed56845..cc4333d2a 100644 --- a/lib/etl/transformers/event_course_splits_strategy.rb +++ b/lib/etl/transformers/event_course_splits_strategy.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl module Transformers class EventCourseSplitsStrategy < BaseTransformer def initialize(parsed_structs, options) diff --git a/lib/etl/transformers/event_group_entrants_strategy.rb b/lib/etl/transformers/event_group_entrants_strategy.rb index b930dd04f..2aaadba8d 100644 --- a/lib/etl/transformers/event_group_entrants_strategy.rb +++ b/lib/etl/transformers/event_group_entrants_strategy.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl module Transformers class EventGroupEntrantsStrategy < BaseTransformer def initialize(parsed_structs, options) diff --git a/lib/etl/transformers/generic_resources_strategy.rb b/lib/etl/transformers/generic_resources_strategy.rb index 7a60a2c99..3bd86328f 100644 --- a/lib/etl/transformers/generic_resources_strategy.rb +++ b/lib/etl/transformers/generic_resources_strategy.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl module Transformers class GenericResourcesStrategy < BaseTransformer def initialize(parsed_structs, options) diff --git a/lib/etl/transformers/jsonapi_batch_strategy.rb b/lib/etl/transformers/jsonapi_batch_strategy.rb index fb3005e03..1c03f723d 100644 --- a/lib/etl/transformers/jsonapi_batch_strategy.rb +++ b/lib/etl/transformers/jsonapi_batch_strategy.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl module Transformers class JsonapiBatchStrategy < BaseTransformer def initialize(parsed_structs, options) diff --git a/lib/etl/transformers/lottery_entrants_strategy.rb b/lib/etl/transformers/lottery_entrants_strategy.rb index a5d5e6ece..b27107c57 100644 --- a/lib/etl/transformers/lottery_entrants_strategy.rb +++ b/lib/etl/transformers/lottery_entrants_strategy.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl module Transformers class LotteryEntrantsStrategy < BaseTransformer def initialize(parsed_structs, options) diff --git a/lib/etl/transformers/race_result_api_split_times_strategy.rb b/lib/etl/transformers/race_result_api_split_times_strategy.rb index 0365c0a5c..dbe47f22a 100644 --- a/lib/etl/transformers/race_result_api_split_times_strategy.rb +++ b/lib/etl/transformers/race_result_api_split_times_strategy.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl module Transformers # The RaceResult API is ideal for importing times, because it provides # absolute times, avoiding the calculation complexity required when diff --git a/lib/etl/transformers/race_result_entrants_strategy.rb b/lib/etl/transformers/race_result_entrants_strategy.rb index 5c2755f23..b060ee9be 100644 --- a/lib/etl/transformers/race_result_entrants_strategy.rb +++ b/lib/etl/transformers/race_result_entrants_strategy.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl module Transformers class RaceResultEntrantsStrategy < BaseTransformer def initialize(parsed_structs, options) diff --git a/lib/etl/transformers/race_result_split_times_strategy.rb b/lib/etl/transformers/race_result_split_times_strategy.rb index 5dffa8dc8..8432031d6 100644 --- a/lib/etl/transformers/race_result_split_times_strategy.rb +++ b/lib/etl/transformers/race_result_split_times_strategy.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ETL +module Etl module Transformers class RaceResultSplitTimesStrategy < BaseTransformer def initialize(parsed_structs, options) diff --git a/lib/tasks/pull_event_data.rake b/lib/tasks/pull_event_data.rake index 5f88dd235..ef33c9a91 100644 --- a/lib/tasks/pull_event_data.rake +++ b/lib/tasks/pull_event_data.rake @@ -1,23 +1,23 @@ -require "etl/etl" +require "etl" namespace :pull_event do desc "Pulls and imports full event data including effort information from my.raceresult.com into an event" task :race_result_full, [:event_id, :rr_event_id, :rr_contest_id, :rr_format] => :environment do |_, args| - source_uri = ETL::Helpers::RaceResultUriBuilder + source_uri = Etl::Helpers::RaceResultUriBuilder .new(args[:rr_event_id], args[:rr_contest_id], args[:rr_format]).full_uri Rake::Task["pull_event:from_uri"].invoke(args[:event_id], source_uri, :race_result_full) end desc "Pulls and imports entrant data (without times) from my.raceresult.com into an event" task :race_result_entrants, [:event_id, :rr_event_id, :rr_contest_id, :rr_format] => :environment do |_, args| - source_uri = ETL::Helpers::RaceResultUriBuilder + source_uri = Etl::Helpers::RaceResultUriBuilder .new(args[:rr_event_id], args[:rr_contest_id], args[:rr_format]).full_uri Rake::Task["pull_event:from_uri"].invoke(args[:event_id], source_uri, :race_result_entrants) end desc "Pulls and imports time data from my.raceresult.com into an event having existing efforts" task :race_result_api_times, [:event_id, :rr_event_id, :rr_api_key] => :environment do |_, args| - source_uri = ETL::Helpers::RaceResultApiUriBuilder + source_uri = Etl::Helpers::RaceResultApiUriBuilder .new(args[:rr_event_id], args[:rr_api_key]).full_uri Rake::Task["pull_event:from_uri"].invoke(args[:event_id], source_uri, :race_result_api_times) end diff --git a/spec/lib/etl/async_importer_spec.rb b/spec/lib/etl/async_importer_spec.rb index 58d08e0c3..79ee9b4da 100644 --- a/spec/lib/etl/async_importer_spec.rb +++ b/spec/lib/etl/async_importer_spec.rb @@ -2,8 +2,8 @@ require "rails_helper" -RSpec.describe ETL::AsyncImporter do - subject { ETL::AsyncImporter.new(import_job) } +RSpec.describe Etl::AsyncImporter do + subject { Etl::AsyncImporter.new(import_job) } let(:import_job) do create( :import_job, diff --git a/spec/lib/etl/csv_templates_spec.rb b/spec/lib/etl/csv_templates_spec.rb index 4d9a44a5d..f6b3f0519 100644 --- a/spec/lib/etl/csv_templates_spec.rb +++ b/spec/lib/etl/csv_templates_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe ETL::CsvTemplates do +RSpec.describe Etl::CsvTemplates do subject { described_class.new(format, parent) } let(:format) { :event_course_splits } diff --git a/spec/lib/etl/extractors/adilas_bear_html_strategy_spec.rb b/spec/lib/etl/extractors/adilas_bear_html_strategy_spec.rb index 2a4078e89..9b160e3c8 100644 --- a/spec/lib/etl/extractors/adilas_bear_html_strategy_spec.rb +++ b/spec/lib/etl/extractors/adilas_bear_html_strategy_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe ::ETL::Extractors::AdilasBearHTMLStrategy do +RSpec.describe ::Etl::Extractors::AdilasBearHtmlStrategy do subject { described_class.new(source_data, options) } let(:source_data) do ::VCR.use_cassette("adilas/#{url.split('?').last}") do diff --git a/spec/lib/etl/extractors/csv_file_strategy_spec.rb b/spec/lib/etl/extractors/csv_file_strategy_spec.rb index cd8320d1e..cc32f00fb 100644 --- a/spec/lib/etl/extractors/csv_file_strategy_spec.rb +++ b/spec/lib/etl/extractors/csv_file_strategy_spec.rb @@ -2,8 +2,8 @@ require "rails_helper" -RSpec.describe ETL::Extractors::CsvFileStrategy do - subject { ETL::Extractors::CsvFileStrategy.new(file, options) } +RSpec.describe Etl::Extractors::CsvFileStrategy do + subject { Etl::Extractors::CsvFileStrategy.new(file, options) } let(:options) { {} } describe "#extract" do diff --git a/spec/lib/etl/extractors/its_your_race_html_strategy_spec.rb b/spec/lib/etl/extractors/its_your_race_html_strategy_spec.rb index 2e2559588..a3c9ac120 100644 --- a/spec/lib/etl/extractors/its_your_race_html_strategy_spec.rb +++ b/spec/lib/etl/extractors/its_your_race_html_strategy_spec.rb @@ -3,7 +3,7 @@ require "rails_helper" require "open-uri" -RSpec.describe ::ETL::Extractors::ItsYourRaceHTMLStrategy do +RSpec.describe ::Etl::Extractors::ItsYourRaceHtmlStrategy do subject { described_class.new(source_data, options) } let(:source_data) do ::VCR.use_cassette("itsyourrace/#{url.split('/').last}") do diff --git a/spec/lib/etl/extractors/pass_through_strategy_spec.rb b/spec/lib/etl/extractors/pass_through_strategy_spec.rb index 6151f6174..14b2701ec 100644 --- a/spec/lib/etl/extractors/pass_through_strategy_spec.rb +++ b/spec/lib/etl/extractors/pass_through_strategy_spec.rb @@ -1,5 +1,5 @@ -RSpec.describe ETL::Extractors::PassThroughStrategy do - subject { ETL::Extractors::PassThroughStrategy.new(raw_data, options) } +RSpec.describe Etl::Extractors::PassThroughStrategy do + subject { Etl::Extractors::PassThroughStrategy.new(raw_data, options) } let(:options) { {model: :effort} } describe "#extract" do diff --git a/spec/lib/etl/extractors/race_result_api_strategy_spec.rb b/spec/lib/etl/extractors/race_result_api_strategy_spec.rb index 7acec5a4e..1e0bed360 100644 --- a/spec/lib/etl/extractors/race_result_api_strategy_spec.rb +++ b/spec/lib/etl/extractors/race_result_api_strategy_spec.rb @@ -2,8 +2,8 @@ require "rails_helper" -RSpec.describe ETL::Extractors::RaceResultApiStrategy do - subject { ETL::Extractors::RaceResultApiStrategy.new(raw_data, options) } +RSpec.describe Etl::Extractors::RaceResultApiStrategy do + subject { Etl::Extractors::RaceResultApiStrategy.new(raw_data, options) } let(:raw_data) do {"list" => {"last_change" => "2016-06-04 21:58:25", "orders" => [], diff --git a/spec/lib/etl/extractors/race_result_strategy_spec.rb b/spec/lib/etl/extractors/race_result_strategy_spec.rb index 98943c227..b094b4c60 100644 --- a/spec/lib/etl/extractors/race_result_strategy_spec.rb +++ b/spec/lib/etl/extractors/race_result_strategy_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -RSpec.describe ETL::Extractors::RaceResultStrategy do - subject { ETL::Extractors::RaceResultStrategy.new(raw_data, options) } +RSpec.describe Etl::Extractors::RaceResultStrategy do + subject { Etl::Extractors::RaceResultStrategy.new(raw_data, options) } let(:raw_data) do {"list" => {"last_change" => "2016-06-04 21:58:25", "orders" => [], diff --git a/spec/lib/etl/importer_spec.rb b/spec/lib/etl/importer_spec.rb index fba0b8ac4..b407d4dec 100644 --- a/spec/lib/etl/importer_spec.rb +++ b/spec/lib/etl/importer_spec.rb @@ -2,8 +2,8 @@ require "rails_helper" -RSpec.describe ETL::Importer do - subject { ETL::Importer.new(source_data, data_format, options) } +RSpec.describe Etl::Importer do + subject { Etl::Importer.new(source_data, data_format, options) } context "when importing efforts using :csv_efforts" do let(:source_data) { file_fixture("test_efforts_utf_8.csv") } diff --git a/spec/lib/etl/loaders/async/insert_strategy_spec.rb b/spec/lib/etl/loaders/async/insert_strategy_spec.rb index 6bf8d4071..e5297057d 100644 --- a/spec/lib/etl/loaders/async/insert_strategy_spec.rb +++ b/spec/lib/etl/loaders/async/insert_strategy_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe ETL::Loaders::Async::InsertStrategy do +RSpec.describe Etl::Loaders::Async::InsertStrategy do subject { described_class.new(proto_records, options) } let(:event) { events(:ggd30_50k) } let(:start_time) { event.scheduled_start_time } diff --git a/spec/lib/etl/loaders/async/ultrasignup_order_id_compare_strategy_spec.rb b/spec/lib/etl/loaders/async/ultrasignup_order_id_compare_strategy_spec.rb index c481e651f..533ddee43 100644 --- a/spec/lib/etl/loaders/async/ultrasignup_order_id_compare_strategy_spec.rb +++ b/spec/lib/etl/loaders/async/ultrasignup_order_id_compare_strategy_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe ETL::Loaders::Async::UltrasignupOrderIdCompareStrategy do +RSpec.describe Etl::Loaders::Async::UltrasignupOrderIdCompareStrategy do subject { described_class.new(proto_records, options) } let(:options) { { import_job: import_job } } let!(:import_job) { create(:import_job, parent: organization, format: :test_format) } diff --git a/spec/lib/etl/loaders/insert_strategy_spec.rb b/spec/lib/etl/loaders/insert_strategy_spec.rb index 5a4f37224..1ec02a3af 100644 --- a/spec/lib/etl/loaders/insert_strategy_spec.rb +++ b/spec/lib/etl/loaders/insert_strategy_spec.rb @@ -2,8 +2,8 @@ require "rails_helper" -RSpec.describe ETL::Loaders::InsertStrategy do - subject { ETL::Loaders::InsertStrategy.new(proto_records, options) } +RSpec.describe Etl::Loaders::InsertStrategy do + subject { Etl::Loaders::InsertStrategy.new(proto_records, options) } let(:event) { events(:ggd30_50k) } let(:start_time) { event.scheduled_start_time } let(:subject_splits) { event.ordered_splits } diff --git a/spec/lib/etl/loaders/split_time_upsert_strategy_spec.rb b/spec/lib/etl/loaders/split_time_upsert_strategy_spec.rb index da8640172..24b45d5a9 100644 --- a/spec/lib/etl/loaders/split_time_upsert_strategy_spec.rb +++ b/spec/lib/etl/loaders/split_time_upsert_strategy_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe ETL::Loaders::SplitTimeUpsertStrategy do +RSpec.describe Etl::Loaders::SplitTimeUpsertStrategy do let(:event) { events(:ggd30_50k) } let(:start_time) { event.scheduled_start_time } let(:subject_splits) { event.ordered_splits } @@ -77,7 +77,7 @@ describe "#load_records" do context "when no matching parent records exist" do - subject { ETL::Loaders::SplitTimeUpsertStrategy.new(valid_proto_records, options) } + subject { Etl::Loaders::SplitTimeUpsertStrategy.new(valid_proto_records, options) } it "does not import any records and places all parent records into ignored_records" do expect { subject.load_records }.to change { Effort.count }.by(0).and change { SplitTime.count }.by(0) @@ -86,7 +86,7 @@ end context "when matching parent records exist for proto_records" do - subject { ETL::Loaders::SplitTimeUpsertStrategy.new(valid_proto_records, options) } + subject { Etl::Loaders::SplitTimeUpsertStrategy.new(valid_proto_records, options) } let!(:effort_1) { create(:effort, event: event, bib_number: valid_proto_records.first[:bib_number]) } let!(:effort_3) { create(:effort, event: event, bib_number: valid_proto_records.third[:bib_number]) } @@ -131,7 +131,7 @@ bitkey: second_child[:sub_split_bitkey], absolute_time: start_time + 1000) end - subject { ETL::Loaders::SplitTimeUpsertStrategy.new(valid_proto_records, options) } + subject { Etl::Loaders::SplitTimeUpsertStrategy.new(valid_proto_records, options) } it "finds existing records based on a unique key and updates provided fields" do existing_effort.reload @@ -173,7 +173,7 @@ bitkey: fifth_child[:sub_split_bitkey], absolute_time: start_time + 4000) end - subject { ETL::Loaders::SplitTimeUpsertStrategy.new(valid_proto_records, options) } + subject { Etl::Loaders::SplitTimeUpsertStrategy.new(valid_proto_records, options) } it "finds existing records based on a unique key and deletes times where blanks exist" do existing_effort.reload @@ -197,7 +197,7 @@ bitkey: second_child[:sub_split_bitkey], absolute_time: start_time + 1000, stopped_here: true) end - subject { ETL::Loaders::SplitTimeUpsertStrategy.new(valid_proto_records, options) } + subject { Etl::Loaders::SplitTimeUpsertStrategy.new(valid_proto_records, options) } it "sets the stop on the last split_time" do existing_effort.reload @@ -224,7 +224,7 @@ bitkey: second_child[:sub_split_bitkey], absolute_time: start_time + 1000) end - subject { ETL::Loaders::SplitTimeUpsertStrategy.new(proto_with_invalid_child, options) } + subject { Etl::Loaders::SplitTimeUpsertStrategy.new(proto_with_invalid_child, options) } it "does not create any child records for the related parent record" do expect { subject.load_records }.to change { Effort.count }.by(0).and change { SplitTime.count }.by(0) diff --git a/spec/lib/etl/loaders/upsert_strategy_spec.rb b/spec/lib/etl/loaders/upsert_strategy_spec.rb index 72d75efd3..fa2bc15c8 100644 --- a/spec/lib/etl/loaders/upsert_strategy_spec.rb +++ b/spec/lib/etl/loaders/upsert_strategy_spec.rb @@ -2,8 +2,8 @@ require "rails_helper" -RSpec.describe ETL::Loaders::UpsertStrategy do - subject { ETL::Loaders::UpsertStrategy.new(proto_records, options) } +RSpec.describe Etl::Loaders::UpsertStrategy do + subject { Etl::Loaders::UpsertStrategy.new(proto_records, options) } let(:course) { create(:course, id: 10) } let(:event) { create(:event, id: 1, course: course) } diff --git a/spec/lib/etl/transformers/adilas_bear_strategy_spec.rb b/spec/lib/etl/transformers/adilas_bear_strategy_spec.rb index 6916a294a..feedfd6b4 100644 --- a/spec/lib/etl/transformers/adilas_bear_strategy_spec.rb +++ b/spec/lib/etl/transformers/adilas_bear_strategy_spec.rb @@ -2,8 +2,8 @@ require "rails_helper" -RSpec.describe ETL::Transformers::AdilasBearStrategy do - subject { ETL::Transformers::AdilasBearStrategy.new(struct, options) } +RSpec.describe Etl::Transformers::AdilasBearStrategy do + subject { Etl::Transformers::AdilasBearStrategy.new(struct, options) } let(:struct) { OpenStruct.new(attributes) } let(:attributes) { {full_name: "Linda McFadden", bib_number: "187", gender: "F", age: "54", city: "Modesto", state_code: "CA", times: times, dnf: dnf} } diff --git a/spec/lib/etl/transformers/async/efforts_with_times_strategy_spec.rb b/spec/lib/etl/transformers/async/efforts_with_times_strategy_spec.rb index 1a07391c9..c5834b068 100644 --- a/spec/lib/etl/transformers/async/efforts_with_times_strategy_spec.rb +++ b/spec/lib/etl/transformers/async/efforts_with_times_strategy_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe ETL::Transformers::Async::EffortsWithTimesStrategy do +RSpec.describe Etl::Transformers::Async::EffortsWithTimesStrategy do subject { described_class.new(structs, options) } let(:options) do diff --git a/spec/lib/etl/transformers/async/hardrock_historical_facts_strategy_spec.rb b/spec/lib/etl/transformers/async/hardrock_historical_facts_strategy_spec.rb index dff3a26c6..e342e37c1 100644 --- a/spec/lib/etl/transformers/async/hardrock_historical_facts_strategy_spec.rb +++ b/spec/lib/etl/transformers/async/hardrock_historical_facts_strategy_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe ETL::Transformers::Async::HardrockHistoricalFactsStrategy do +RSpec.describe Etl::Transformers::Async::HardrockHistoricalFactsStrategy do subject { described_class.new(structs, options) } let(:options) do diff --git a/spec/lib/etl/transformers/async/historical_facts_strategy_spec.rb b/spec/lib/etl/transformers/async/historical_facts_strategy_spec.rb index e63cc3eba..c57a29e3b 100644 --- a/spec/lib/etl/transformers/async/historical_facts_strategy_spec.rb +++ b/spec/lib/etl/transformers/async/historical_facts_strategy_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe ETL::Transformers::Async::HistoricalFactsStrategy do +RSpec.describe Etl::Transformers::Async::HistoricalFactsStrategy do subject { described_class.new(structs, options) } let(:options) do diff --git a/spec/lib/etl/transformers/async/null_strategy_spec.rb b/spec/lib/etl/transformers/async/null_strategy_spec.rb index 8028681c1..909454c0e 100644 --- a/spec/lib/etl/transformers/async/null_strategy_spec.rb +++ b/spec/lib/etl/transformers/async/null_strategy_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe ETL::Transformers::Async::NullStrategy do +RSpec.describe Etl::Transformers::Async::NullStrategy do subject { described_class.new(structs, options) } let(:options) do diff --git a/spec/lib/etl/transformers/async/ultrasignup_historical_facts_strategy_spec.rb b/spec/lib/etl/transformers/async/ultrasignup_historical_facts_strategy_spec.rb index b0bb0a80d..6df9250ef 100644 --- a/spec/lib/etl/transformers/async/ultrasignup_historical_facts_strategy_spec.rb +++ b/spec/lib/etl/transformers/async/ultrasignup_historical_facts_strategy_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe ETL::Transformers::Async::UltrasignupHistoricalFactsStrategy do +RSpec.describe Etl::Transformers::Async::UltrasignupHistoricalFactsStrategy do subject { described_class.new(structs, options) } let(:options) do diff --git a/spec/lib/etl/transformers/elapsed_incremental_aid_strategy_spec.rb b/spec/lib/etl/transformers/elapsed_incremental_aid_strategy_spec.rb index 648b23b49..6001ae037 100644 --- a/spec/lib/etl/transformers/elapsed_incremental_aid_strategy_spec.rb +++ b/spec/lib/etl/transformers/elapsed_incremental_aid_strategy_spec.rb @@ -2,8 +2,8 @@ require "rails_helper" -RSpec.describe ETL::Transformers::ElapsedIncrementalAidStrategy do - subject { ETL::Transformers::ElapsedIncrementalAidStrategy.new(struct, options) } +RSpec.describe Etl::Transformers::ElapsedIncrementalAidStrategy do + subject { Etl::Transformers::ElapsedIncrementalAidStrategy.new(struct, options) } let(:struct) { OpenStruct.new(attributes) } let(:attributes) { {full_name: "William Abel", gender: "male", age: "41", city: "Byron", state_code: "IL", times: times} } diff --git a/spec/lib/etl/transformers/event_group_entrants_strategy_spec.rb b/spec/lib/etl/transformers/event_group_entrants_strategy_spec.rb index 3a3855c9b..e5b2eabdc 100644 --- a/spec/lib/etl/transformers/event_group_entrants_strategy_spec.rb +++ b/spec/lib/etl/transformers/event_group_entrants_strategy_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe ::ETL::Transformers::EventGroupEntrantsStrategy do +RSpec.describe ::Etl::Transformers::EventGroupEntrantsStrategy do subject { described_class.new(parsed_structs, options) } let(:proto_records) { subject.transform } diff --git a/spec/lib/etl/transformers/generic_resources_strategy_spec.rb b/spec/lib/etl/transformers/generic_resources_strategy_spec.rb index 9a818d554..57f7d9101 100644 --- a/spec/lib/etl/transformers/generic_resources_strategy_spec.rb +++ b/spec/lib/etl/transformers/generic_resources_strategy_spec.rb @@ -2,8 +2,8 @@ require "rails_helper" -RSpec.describe ETL::Transformers::GenericResourcesStrategy do - subject { ETL::Transformers::GenericResourcesStrategy.new(parsed_structs, options) } +RSpec.describe Etl::Transformers::GenericResourcesStrategy do + subject { Etl::Transformers::GenericResourcesStrategy.new(parsed_structs, options) } let(:course) { build_stubbed(:course, id: 10) } let(:event) { build_stubbed(:event, id: 1, course: course) } diff --git a/spec/lib/etl/transformers/jsonapi_batch_strategy_spec.rb b/spec/lib/etl/transformers/jsonapi_batch_strategy_spec.rb index 880c2fdfd..e57b95e70 100644 --- a/spec/lib/etl/transformers/jsonapi_batch_strategy_spec.rb +++ b/spec/lib/etl/transformers/jsonapi_batch_strategy_spec.rb @@ -1,7 +1,7 @@ require "rails_helper" -RSpec.describe ETL::Transformers::JsonapiBatchStrategy do - subject { ETL::Transformers::JsonapiBatchStrategy.new(parsed_structs, options) } +RSpec.describe Etl::Transformers::JsonapiBatchStrategy do + subject { Etl::Transformers::JsonapiBatchStrategy.new(parsed_structs, options) } let(:course) { build_stubbed(:course, id: 10) } let(:event) { build_stubbed(:event, id: 1, course: course) } diff --git a/spec/lib/etl/transformers/lottery_entrants_strategy_spec.rb b/spec/lib/etl/transformers/lottery_entrants_strategy_spec.rb index 71757bf74..b5597742c 100644 --- a/spec/lib/etl/transformers/lottery_entrants_strategy_spec.rb +++ b/spec/lib/etl/transformers/lottery_entrants_strategy_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe ::ETL::Transformers::LotteryEntrantsStrategy do +RSpec.describe ::Etl::Transformers::LotteryEntrantsStrategy do subject { described_class.new(parsed_structs, options) } let(:lottery) { lotteries(:lottery_without_tickets) } diff --git a/spec/lib/etl/transformers/race_result_api_split_times_strategy_spec.rb b/spec/lib/etl/transformers/race_result_api_split_times_strategy_spec.rb index 2a5bbc1c0..4be9308e6 100644 --- a/spec/lib/etl/transformers/race_result_api_split_times_strategy_spec.rb +++ b/spec/lib/etl/transformers/race_result_api_split_times_strategy_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe ETL::Transformers::RaceResultApiSplitTimesStrategy do +RSpec.describe Etl::Transformers::RaceResultApiSplitTimesStrategy do subject { described_class.new(parsed_structs, options) } let(:options) { {parent: event}.merge(delete_blank_times_option).merge(ignore_time_indices_option) } let(:delete_blank_times_option) { {} } diff --git a/spec/lib/etl/transformers/race_result_split_times_strategy_spec.rb b/spec/lib/etl/transformers/race_result_split_times_strategy_spec.rb index 37f16cfd3..1f2643f1e 100644 --- a/spec/lib/etl/transformers/race_result_split_times_strategy_spec.rb +++ b/spec/lib/etl/transformers/race_result_split_times_strategy_spec.rb @@ -2,8 +2,8 @@ require "rails_helper" -RSpec.describe ETL::Transformers::RaceResultSplitTimesStrategy do - subject { ETL::Transformers::RaceResultSplitTimesStrategy.new(parsed_structs, options) } +RSpec.describe Etl::Transformers::RaceResultSplitTimesStrategy do + subject { Etl::Transformers::RaceResultSplitTimesStrategy.new(parsed_structs, options) } let(:options) { {parent: event} } let(:proto_records) { subject.transform } let(:first_proto_record) { proto_records.first } diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index b3c9ed8b4..ba1b7d7ad 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -22,7 +22,6 @@ require "aws-sdk-s3" require "aws-sdk-sns" require "paper_trail/frameworks/rspec" -require "etl/etl" require "open-uri" WebMock.disable_net_connect!(allow_localhost: true)