-
Notifications
You must be signed in to change notification settings - Fork 9
Make the gem work without ActiveRecord #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
cc00450
c8c97da
8008b76
5724f7b
7fc0d6a
3acbed0
75b719c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,5 +8,6 @@ | |
| /spec/dummy/log/*.log | ||
| /spec/dummy/storage/ | ||
| /spec/dummy/tmp/ | ||
| .DS_Store | ||
| .rspec_status | ||
| .yardoc | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,13 +4,10 @@ | |
| require 'i18n' | ||
| require 'httparty' | ||
| require 'google/cloud/bigquery' | ||
| require 'dfe/analytics/activerecord' if defined?(ActiveRecord) | ||
| require 'dfe/analytics/event_schema' | ||
| require 'dfe/analytics/fields' | ||
| require 'dfe/analytics/entities' | ||
| require 'dfe/analytics/services/entity_table_checks' | ||
| require 'dfe/analytics/services/checksum_calculator' | ||
| require 'dfe/analytics/services/generic_checksum_calculator' | ||
| require 'dfe/analytics/services/postgres_checksum_calculator' | ||
| require 'dfe/analytics/shared/service_pattern' | ||
| require 'dfe/analytics/event' | ||
| require 'dfe/analytics/event_matcher' | ||
|
|
@@ -28,7 +25,6 @@ | |
| require 'dfe/analytics/big_query_api' | ||
| require 'dfe/analytics/big_query_legacy_api' | ||
| require 'dfe/analytics/azure_federated_auth' | ||
| require 'dfe/analytics/transaction_changes' | ||
|
|
||
| module DfE | ||
| module Analytics | ||
|
|
@@ -96,19 +92,21 @@ def self.configure | |
| end | ||
|
|
||
| def self.initialize! | ||
| unless defined?(ActiveRecord) | ||
| # bail if we don't have AR at all | ||
| Rails.logger.error('ActiveRecord not loaded; DfE Analytics not initialized') | ||
| return | ||
| end | ||
|
|
||
| unless Rails.env.production? || File.exist?(Rails.root.join('config/initializers/dfe_analytics.rb')) | ||
| message = "Warning: DfE Analytics is not set up. Run: 'bundle exec rails generate dfe:analytics:install'" | ||
| Rails.logger.error(message) | ||
| puts message | ||
| return | ||
| end | ||
|
|
||
| if defined?(ActiveRecord) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We may want to introduce a config item, such as
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did try that but the gem code would throw an error while loading in the Rails app. I agree that a config item would be nice, but maybe we can do it as an improvement in the future.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What was the error?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got a
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @goodviber Thanks. I haven't tested it with an app running ActiveRecord. Does the test suite not cover that? |
||
| setup_entities | ||
| else | ||
| Rails.logger.info('ActiveRecord not loaded; DfE Analytics will only track non-database requests.') | ||
| end | ||
| end | ||
|
|
||
| def self.setup_entities | ||
| if Rails.version.to_f > 7.1 | ||
| ActiveRecord::Base.with_connection do |connection| | ||
| raise ActiveRecord::PendingMigrationError if connection.pool.migration_context.needs_migration? | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'dfe/analytics/services/entity_table_checks' | ||
| require 'dfe/analytics/services/checksum_calculator' | ||
| require 'dfe/analytics/services/generic_checksum_calculator' | ||
| require 'dfe/analytics/services/postgres_checksum_calculator' | ||
| require 'dfe/analytics/transaction_changes' |
Uh oh!
There was an error while loading. Please reload this page.